-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[Discover] Fix sidebar element focus behavior when adding / removing columns #75749
[Discover] Fix sidebar element focus behavior when adding / removing columns #75749
Conversation
@@ -29,6 +29,5 @@ export function createDiscoverSidebarDirective(reactDirective: any) { | |||
['onRemoveField', { watchDepth: 'reference' }], | |||
['selectedIndexPattern', { watchDepth: 'reference' }], | |||
['setIndexPattern', { watchDepth: 'reference' }], | |||
['state', { watchDepth: 'reference' }], |
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.
PR also contains a few cleanups of unused state variable
Pinging @elastic/kibana-app (Team:KibanaApp) |
@kertal seems like there's some weird jumps of the |
good catch, so it's because of the |
@kertal Not 100% sure I'm following, could this be a bug on the EUI side then? |
No, it's the way Chrome chooses, which element to focus, when you remove the Popover.
|
@elasticmachine merge upstream |
…-24-fix-discover-sidebar-focus-behavior
- when adding field
…r' of github.com:kertal/kibana into kertal-pr-2020-08-24-fix-discover-sidebar-focus-behavior
if (ev.type === 'click') { | ||
ev.currentTarget.focus(); | ||
} |
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.
@andreadelrio this should prevent Chrome from setting focus to the last focused sidebar element in case of a click
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.
Tested this and it seems to solve the issue properly.
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, thanks for making the adjustments.
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.
Code LGTM, I tested it mainly on Chrome but also made some tests on Safari and FF, the bug is solved 🙂
<button onClick={onClick} {...buttonProps} className={buttonClasses}> | ||
<button | ||
onClick={(e) => { | ||
if (e.type === 'click') { |
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.
Curious, if it is ever something else than 'click'
?
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.
yes, it could also be triggered by an enter key, but in this case it should already have focus
I don't think this is a native behaviour. With that in mind, I guess there is a way for EUI popover to expose more granular apis for handling focus locking. Not sure if it worth it in this case or if we are OK with proposed solution. |
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.
Could you please check if we need the change in (confirmed with @kertal that we indeed need this), LGTM, checked on Chome/Mac.field_button.tsx
, I'm thinking maybe this issue is already fixed with the other changes, but if we do
@Dosant thx for the context and input! dear @chandlerprall & @thompsongl, are you a ok with the suggested solution to manually set focus before the EuiPopover takes focus over, or is there something that can be done on EUI side? thx |
@elasticmachine merge upstream |
Definitely worth looking into EUI's focus trap integration more. The demonstrated behaviour is unexpected, at worst I would expect it to flash focus back to the previously clicked button, not the first item in the list. I would create an EUI issue and link to it in your onClick->focus fix, so if we can resolve the issue in EUI it's a quick path back to removing this patch. |
@chandlerprall Right, so I will merge this, and create an EUI issue and link it |
💚 Build SucceededBuild metricsasync chunks size
page load bundle size
History
To update your PR or re-run it, just comment with: |
…columns (elastic#75749) * Use field.name instead of idx for key in li element * onClick adds focus to button * prevent Chrome jumping back to last focused element
…nes/processors-forms-k-s * 'master' of github.com:elastic/kibana: (216 commits) [Ingest Manager] Split Registry errors into Connection & Response (elastic#76558) [Security Solution] add an excess validation instead of the exact match (elastic#76472) Introduce TS incremental builds & move src/test_utils to TS project (elastic#76082) fix bad merge (elastic#76629) [Newsfeed] Ensure the version format when calling the API (elastic#76381) remove server_extensions mixin (elastic#76606) Remove legacy applications and legacy mode (elastic#75987) [Discover] Fix sidebar element focus behavior when adding / removing columns (elastic#75749) Replace FetchOptions with ISearchOptions (elastic#76538) Move streams utils to the core (elastic#76397) [Ingest Manager] Wording & linking improvements (elastic#76284) remove legacy kibana plugin (elastic#76064) [Form lib] Fix regression on field not being validated after reset to its default value. (elastic#76379) Legacy SO import: Fix bug causing multiple overrides to only show the last confirm modal (elastic#76482) [APM] Service maps layout enhancements (elastic#76481) [Security Solution][Detection Engine] Remove RuleTypeSchema in favor of Type for TypeScript (elastic#76586) [Security Solution][Exceptions] - Updates enum schema and tests (elastic#76544) Index Pattern class - remove toJSON and toString (elastic#76246) skip failing suite (elastic#76581) Split up and clarify Enterprise Search codeowners (elastic#76580) ... # Conflicts: # x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/manage_processor_form/processor_settings_fields.tsx # x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/manage_processor_form/processors/foreach.tsx
…oleysens/kibana into ingest-pipelines/processors-forms-k-s * 'ingest-pipelines/processors-forms-k-s' of github.com:jloleysens/kibana: (216 commits) [Ingest Manager] Split Registry errors into Connection & Response (elastic#76558) [Security Solution] add an excess validation instead of the exact match (elastic#76472) Introduce TS incremental builds & move src/test_utils to TS project (elastic#76082) fix bad merge (elastic#76629) [Newsfeed] Ensure the version format when calling the API (elastic#76381) remove server_extensions mixin (elastic#76606) Remove legacy applications and legacy mode (elastic#75987) [Discover] Fix sidebar element focus behavior when adding / removing columns (elastic#75749) Replace FetchOptions with ISearchOptions (elastic#76538) Move streams utils to the core (elastic#76397) [Ingest Manager] Wording & linking improvements (elastic#76284) remove legacy kibana plugin (elastic#76064) [Form lib] Fix regression on field not being validated after reset to its default value. (elastic#76379) Legacy SO import: Fix bug causing multiple overrides to only show the last confirm modal (elastic#76482) [APM] Service maps layout enhancements (elastic#76481) [Security Solution][Detection Engine] Remove RuleTypeSchema in favor of Type for TypeScript (elastic#76586) [Security Solution][Exceptions] - Updates enum schema and tests (elastic#76544) Index Pattern class - remove toJSON and toString (elastic#76246) skip failing suite (elastic#76581) Split up and clarify Enterprise Search codeowners (elastic#76580) ...
* master: (340 commits) [data.search.SearchSource] Remove legacy ES client APIs. (elastic#75943) [release notes] automatically retry on Github API 5xx errors (elastic#76447) [es_ui_shared] Fix eslint exhaustive deps rule (elastic#76392) [i18n] Integrate 7.9.1 Translations (elastic#76391) [APM] Update aggregations to support script sources (elastic#76429) [Security Solution] Refactor Network Top Countries to use Search Strategy (elastic#76244) Document security settings available on ESS (elastic#76513) [Ingest Manager] Add input revision to the config send to the agent (elastic#76327) [DOCS] Identifies cloud settings for Monitoring (elastic#76579) [DOCS] Identifies Cloud settings in Dev Tools (elastic#76583) [Ingest Manager] Better default value for fleet long polling timeout (elastic#76393) [data.indexPatterns] Fix broken rollup index pattern creation (elastic#76593) [Ingest Manager] Split Registry errors into Connection & Response (elastic#76558) [Security Solution] add an excess validation instead of the exact match (elastic#76472) Introduce TS incremental builds & move src/test_utils to TS project (elastic#76082) fix bad merge (elastic#76629) [Newsfeed] Ensure the version format when calling the API (elastic#76381) remove server_extensions mixin (elastic#76606) Remove legacy applications and legacy mode (elastic#75987) [Discover] Fix sidebar element focus behavior when adding / removing columns (elastic#75749) ...
Summary
The
keys
of the sidebar's field elements were generated by the index in the array. So when adding a column to the selected columns, its successor got thekey
of the element just added. This caused the weird behavior in this case (next element got focus, also the field details popover was displayed if it was active before ).To prevent a short flickering in Chrome when clicking on the sidebar element, those elements get focus
onClick
Fixes #72721