1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-10-18 20:09:08 +02:00
unleash.unleash/frontend/src/component/common
Thomas Heartman dd1ab1ca72 Autofocus dialog form fields, allow form submissions via pressing enter inside the form (#524)
* chore: add prettier as a dev dependency

The project has a .prettierrc, so seems to depend on that for its
formatting, but there was no prettier installed with the node modules.

* chore: add autofocus to all clearly defined first inputs on dialogs.

* fix: wrap the disable env input in a form and give it autofocus.

* fix: submit form when pressing enter

* fix: only autofocus the submit button if there is no other content.

When multiple (enabled) elements have the autofocus attribute, the
browser picks the last element in the tree. This means that if there
is a form with a text input with autofocus and a submit button with
autofocus, the button will win, causing the user to have to tab back up.

Only doing this if there are no children will cause some changes,
however:

Dialogs with textual children will no longer focus the accept-button
when appearing.

However, dialogs such as the create new api token dialog will give the
focus to the first input field instead of to the create button.

* fix: add formId prop to dialog element; adapt behavior

If the component receives a form id, it will treat the primary button
as the submit button for that form. To stop a full page reload, we
call the `preventDefault` on the submit event before calling the handler.

* chore: remove redundant spacing in component.

* fix: hook environment disable form up with the new form id system.

* chore: Update existing modal forms to pass in formId

* fix: Type the dialog event wrapper

* fix: change 'allows' => 'allow' because the noun is pluralized.

* fix: add autofocus to js add-tag-dialog-component.

I've got a feeling this component isn't in use anymore, though, as the
exact same text appears in a TS-version of this component.

* fix: add autofocus to add user form.

This seems to only be used as the main piece of a modal, so adding
autofocus seems pretty safe here, but I could be wrong.

* fix: Update snapshot test after changing wording.

* fix: add autofocus to update user form

* fix: add autofocus to the create toggle form.

This is a little besides the task's actual point. However! This form
is only ever used on the page where it's the only bit of content. I'd
argue that when the user navigates to this form, it's because they
want to create a feature. Thus, adding autofocus to the first field
makes a lot of sense to me.

* refactor: set button type to 'undefined' when it isn't 'submit'

This allows Material to use their default type based on whatever
heuristics they use. It's most likely going to be 'button' for the
foreseeable future, but in the event that they change it, passing
undefined instead should future-proof this a bit.

* fix: set type to button when formId is not present

Co-authored-by: Fredrik Strand Oseberg <fredrik.no@gmail.com>
2021-11-29 15:18:12 +01:00
..
__tests__
AnimateOnMount Feat/environment strategies (#339) 2021-09-27 13:35:32 +02:00
ApiError feat: created project header (#388) 2021-10-01 12:15:02 +02:00
BreadcrumbNav fix/breadcrumb (#533) 2021-11-29 14:29:58 +01:00
CheckmarkBadge Feat/environment crud (#335) 2021-09-14 14:20:23 +02:00
ConditionallyRender
Constraint task: Add buttons for deleting/editing a constraint (#522) 2021-11-26 16:07:05 +01:00
Dialogue Autofocus dialog form fields, allow form submissions via pressing enter inside the form (#524) 2021-11-29 15:18:12 +01:00
DisabledIndicator Fix/project view desc (#515) 2021-11-24 14:36:21 +01:00
DividerText
DropdownMenu Feat/feature routes (#327) 2021-08-25 13:37:22 +02:00
EnvironmentIcon Feat/new toggle overview (#497) 2021-11-12 11:47:19 +01:00
EnvironmentSplash Fix/splash (#534) 2021-11-29 14:03:52 +01:00
Feedback
GeneralSelect Fix/environment list sorting (#447) 2021-10-20 12:05:44 +02:00
Gradient
HeaderTitle Feat/environment crud (#335) 2021-09-14 14:20:23 +02:00
Input Feat/feature toggle view tags (#399) 2021-10-08 11:23:29 +02:00
ListPlaceholder
Loader fix: sloader path (#530) 2021-11-26 16:30:39 +01:00
NoItems Feat/new toggle overview (#497) 2021-11-12 11:47:19 +01:00
NotFound
PageContent feat: Add project and environment scoping to API keys (#336) 2021-09-26 22:41:38 +02:00
PaginateUI fix: make toggle list sortable inside a project (#436) 2021-10-15 11:20:14 +02:00
PercentageCircle fix/strategy tab (#519) 2021-11-26 13:36:04 +01:00
PermissionButton Fix/environment list sorting (#447) 2021-10-20 12:05:44 +02:00
PermissionIconButton task: Add buttons for deleting/editing a constraint (#522) 2021-11-26 16:07:05 +01:00
PermissionSwitch Feat/new toggle overview (#497) 2021-11-12 11:47:19 +01:00
Proclamation Feat/new navigation (#314) 2021-07-16 15:41:54 +02:00
ProjectSelect Fix/create feature (#332) 2021-08-30 14:26:53 +02:00
ProtectedRoute
ResponsiveButton Fix/environment list sorting (#447) 2021-10-20 12:05:44 +02:00
RolloutIcon Fix/project view desc (#515) 2021-11-24 14:36:21 +01:00
SearchField fix: typo in function name + remove unused value state 2021-11-24 20:59:23 +01:00
Splash Feat/splash (#491) 2021-11-26 11:12:37 +01:00
StatusChip fix: status chip (#501) 2021-11-12 12:02:47 +01:00
StringTruncator Feat/new toggle overview (#497) 2021-11-12 11:47:19 +01:00
TabNav Feat/environment strategies (#339) 2021-09-27 13:35:32 +02:00
TagSelect Feat/feature toggle view tags (#399) 2021-10-08 11:23:29 +02:00
Toast feat: project environments configuration (#365) 2021-09-30 10:24:16 +02:00
common.module.scss fix: show feature toggle type in list (#418) 2021-10-11 22:45:59 +02:00
flags.js fix: update ui flags 2021-10-14 09:42:17 +02:00
index.js
input-list-field.jsx fix: update constraint text field 2021-08-27 13:43:28 +02:00
select.tsx feat: e2e tests and mobile views (#348) 2021-09-30 11:44:30 +02:00
util.js Fix/variants: Fix delete one variant + remove switch when add first variant (#466) 2021-10-28 13:32:29 +02:00