-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix API Key flyout double submit #167468
Fix API Key flyout double submit #167468
Conversation
Pinging @elastic/kibana-security (Team:Security) |
x-pack/plugins/security/public/management/api_keys/api_keys_grid/api_key_flyout.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is labeled as backport:skip
, but I think this bugfix should be considered for backport to prev-minor
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work on this! The behavior is really close, but I noticed an issue with in-line form feedback. The double-submit is no longer occurring, which is great!
One additional suggestion would be to add aria-labels
to the code editors (role descriptors and metadata). Currently, with a screen reader, these just announce as "code editor", and the aria-label will override this and make it more useful.
e.g.
<FormField
as={CodeEditorField}
name="role_descriptors"
aria-label={
i18n.translate(
'xpack.security.management.apiKeys.apiKeyFlyout.roleDescriptorsCodeEditor',
{
defaultMessage: 'Restrict privileges role descriptors code editor',
}
)
}
...
and the same for the metadata component.
x-pack/plugins/security/public/management/api_keys/api_keys_grid/api_key_flyout.tsx
Outdated
Show resolved
Hide resolved
@@ -60,7 +62,10 @@ export function FormField<T extends ElementType = typeof EuiFieldText>({ | |||
{...field} | |||
{...rest} | |||
onBlur={(event) => { | |||
helpers.setTouched(true); // Marking as touched manually here since some EUI components don't pass on the native blur event which is required by `field.onBlur()`. | |||
if (setTouchedOnBlur) { | |||
helpers.setTouched(setTouchedOnBlur); // Marking as touched manually here since some EUI components don't pass on the native blur event which is required by `field.onBlur()`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I noticed was that while this does help with getting tab order to work as expected, it also keeps form feedback from occurring. See my comment later in api_key_flyout.tsx
@@ -258,6 +267,7 @@ export const ApiKeyFlyout: FunctionComponent<ApiKeyFlyoutProps> = ({ | |||
> | |||
<FormField | |||
name="name" | |||
setTouchedOnBlur={false} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jeramysoucy Good catch! I was investigating this and I've found that whenever a field validator is called it loses tab focus incorrectly. Will investigate and fix!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jeramysoucy Created a separate issue to solve this problem here: #168164
Only solving the form double submit here.
x-pack/plugins/security/public/management/api_keys/api_keys_grid/api_key_flyout.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Just had a question about FormFlyout
. Also, we need to add a version label for the PR. 8.11 is past feature freeze, so probably 8.12.
<EuiFlyoutBody>{children}</EuiFlyoutBody> | ||
<EuiFlyoutFooter> | ||
<EuiFlexGroup justifyContent="spaceBetween"> | ||
<EuiFlyout onClose={onCancel} aria-labelledby={titleId} {...rest}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these changes necessary? Does api_key_flyout
use FormFlyout
? Or is this to just keep things consistent?
Note: I couldn't find any uses of FormFlyout
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think there's another consumer of the FormFlyout component anymore so it would be best to remove it from the codebase
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@thomheymann Thanks for confirming, Thom!
@SiddharthMantri Looks like it's used in the 7.17 branch. So if we have the double submit issue in 7.17 and it's worth fixing, we can open a PR against that branch with the changes to FormFlyout
.
💚 Build Succeeded
Metrics [docs]Module Count
Async chunks
History
To update your PR or re-run it, just comment with: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works as expected. Thanks for the additional clean up!
## Summary Closes elastic#163314 ## Fixes - Removed an extra EuiPortal that was not needed as EuiFlyout adds a Portal - Inverted control of the form by wrapping the flyout content in the form. Prevents multiple submits by using traditional form controls and button type as submit. ## Release Notes: - Fixes issue with multiple API keys being created if the form is submitted using the enter key fired multiple times in quick succession. elastic#163314 --------- Co-authored-by: kibanamachine <[email protected]> (cherry picked from commit e3d9f3d)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
# Backport This will backport the following commits from `main` to `8.11`: - [Fix API Key flyout double submit (#167468)](#167468) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Sid","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-10-10T14:12:45Z","message":"Fix API Key flyout double submit (#167468)\n\n## Summary\r\n\r\nCloses https://github.com/elastic/kibana/issues/163314\r\n\r\n\r\n## Fixes\r\n\r\n- Removed an extra EuiPortal that was not needed as EuiFlyout adds a\r\nPortal\r\n- Inverted control of the form by wrapping the flyout content in the\r\nform. Prevents multiple submits by using traditional form controls and\r\nbutton type as submit.\r\n\r\n\r\n## Release Notes:\r\n\r\n- Fixes issue with multiple API keys being created if the form is\r\nsubmitted using the enter key fired multiple times in quick succession.\r\nhttps://github.com//issues/163314\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <[email protected]>","sha":"e3d9f3d62e403f56b9d3a553338a3c5201edc021","branchLabelMapping":{"^v8.12.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:fix","Team:Security","backport:prev-minor","v8.12.0"],"number":167468,"url":"https://github.com/elastic/kibana/pull/167468","mergeCommit":{"message":"Fix API Key flyout double submit (#167468)\n\n## Summary\r\n\r\nCloses https://github.com/elastic/kibana/issues/163314\r\n\r\n\r\n## Fixes\r\n\r\n- Removed an extra EuiPortal that was not needed as EuiFlyout adds a\r\nPortal\r\n- Inverted control of the form by wrapping the flyout content in the\r\nform. Prevents multiple submits by using traditional form controls and\r\nbutton type as submit.\r\n\r\n\r\n## Release Notes:\r\n\r\n- Fixes issue with multiple API keys being created if the form is\r\nsubmitted using the enter key fired multiple times in quick succession.\r\nhttps://github.com//issues/163314\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <[email protected]>","sha":"e3d9f3d62e403f56b9d3a553338a3c5201edc021"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.12.0","labelRegex":"^v8.12.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/167468","number":167468,"mergeCommit":{"message":"Fix API Key flyout double submit (#167468)\n\n## Summary\r\n\r\nCloses https://github.com/elastic/kibana/issues/163314\r\n\r\n\r\n## Fixes\r\n\r\n- Removed an extra EuiPortal that was not needed as EuiFlyout adds a\r\nPortal\r\n- Inverted control of the form by wrapping the flyout content in the\r\nform. Prevents multiple submits by using traditional form controls and\r\nbutton type as submit.\r\n\r\n\r\n## Release Notes:\r\n\r\n- Fixes issue with multiple API keys being created if the form is\r\nsubmitted using the enter key fired multiple times in quick succession.\r\nhttps://github.com//issues/163314\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <[email protected]>","sha":"e3d9f3d62e403f56b9d3a553338a3c5201edc021"}}]}] BACKPORT--> Co-authored-by: Sid <[email protected]>
## Summary Closes elastic#163314 ## Fixes - Removed an extra EuiPortal that was not needed as EuiFlyout adds a Portal - Inverted control of the form by wrapping the flyout content in the form. Prevents multiple submits by using traditional form controls and button type as submit. ## Release Notes: - Fixes issue with multiple API keys being created if the form is submitted using the enter key fired multiple times in quick succession. elastic#163314 --------- Co-authored-by: kibanamachine <[email protected]>
Summary
Closes #163314
Fixes
Release Notes: