Skip to content
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

Merged
merged 18 commits into from
Oct 10, 2023

Conversation

SiddharthMantri
Copy link
Contributor

@SiddharthMantri SiddharthMantri commented Sep 28, 2023

Summary

Closes #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:

@SiddharthMantri SiddharthMantri marked this pull request as ready for review September 28, 2023 15:44
@SiddharthMantri SiddharthMantri requested a review from a team as a code owner September 28, 2023 15:44
@SiddharthMantri SiddharthMantri added bug Fixes for quality problems that affect the customer experience release_note:fix Team:Security Team focused on: Auth, Users, Roles, Spaces, Audit Logging, and more! labels Sep 28, 2023
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-security (Team:Security)

@SiddharthMantri SiddharthMantri added the backport:skip This commit does not require backporting label Sep 28, 2023
Copy link
Member

@legrego legrego left a 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.

@legrego legrego requested a review from a team September 28, 2023 18:03
@SiddharthMantri SiddharthMantri added backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) and removed backport:skip This commit does not require backporting labels Sep 28, 2023
@jeramysoucy jeramysoucy self-requested a review September 29, 2023 16:01
Copy link
Contributor

@jeramysoucy jeramysoucy left a 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.

@@ -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()`.
Copy link
Contributor

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}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the user tabs past the empty name field they used to get instant feedback that the name is required. With this change, this does not occur.
Screenshot 2023-09-29 at 1 15 41 PM

Copy link
Contributor Author

@SiddharthMantri SiddharthMantri Oct 2, 2023

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!

Copy link
Contributor Author

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.

@SiddharthMantri SiddharthMantri changed the title Fix API Key flyout focus trapping and double submit Fix API Key flyout double submit Oct 5, 2023
Copy link
Contributor

@jeramysoucy jeramysoucy left a 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}>
Copy link
Contributor

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.

Copy link
Contributor

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

Copy link
Contributor

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.

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
security 502 501 -1

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
security 571.4KB 571.1KB -316.0B

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

Copy link
Contributor

@jeramysoucy jeramysoucy left a 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!

@SiddharthMantri SiddharthMantri merged commit e3d9f3d into elastic:main Oct 10, 2023
21 checks passed
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Oct 10, 2023
## 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 <42973632+kibanamachine@users.noreply.github.com>
(cherry picked from commit e3d9f3d)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.11

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Oct 10, 2023
# 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":"siddharthmantri1@gmail.com"},"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
<42973632+kibanamachine@users.noreply.github.com>","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
<42973632+kibanamachine@users.noreply.github.com>","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
<42973632+kibanamachine@users.noreply.github.com>","sha":"e3d9f3d62e403f56b9d3a553338a3c5201edc021"}}]}]
BACKPORT-->

Co-authored-by: Sid <siddharthmantri1@gmail.com>
dej611 pushed a commit to dej611/kibana that referenced this pull request Oct 17, 2023
## 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 <42973632+kibanamachine@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) bug Fixes for quality problems that affect the customer experience release_note:fix Team:Security Team focused on: Auth, Users, Roles, Spaces, Audit Logging, and more! v8.11.0 v8.12.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

API Key flyout UX behavior - double submit
7 participants