-
Notifications
You must be signed in to change notification settings - Fork 844
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
[EuiPopover] Focus on parent popover panel by default, instead of first tabbable child #5784
Conversation
Preview documentation changes for this PR: https://eui.elastic.co/pr_5784/ |
- because EuiPopover's `updateFocus` is called after the transition ends (350ms currently), it supercedes EuiContextMenu's `updateFocus` - I'm not a super huge fan of this DOM-heavy workaround but I can't think of any other options - very open to more ideas
// If EuiContextMenu is used within an EuiPopover, EuiPopover's own | ||
// `updateFocus()` method hijacks EuiContextMenuPanel's `updateFocus()` | ||
// 350ms after the popover finishes transitioning in. This workaround | ||
// reclaims focus from parent EuiPopovers that do not set an `initialFocus` | ||
reclaimPopoverFocus() { |
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.
Just to add more context for this commit (4958d95), which attempts to resolve #4973:
Unfortunately after testing both #5783 and #5784 together, focus still wasn't working as expected - EuiPopover was still taking focus away from EuiContextMenuPanel, and I don't think we can realistically ask every single consumer to always set <EuiPopover initialFocus={false} />
in conjunction with <EuiContextMenu />
. I mean we can, but I think they'll forget to do it, and I'd rather use a workaround to ensure keyboard users aren't SOL.
I'm not a super huge fan of this DOM-heavy workaround but I think it's better than adding a hard-coded 350ms setTimeout to EuiContextMenuPanel 😬 Definitely open to other ideas/alternatives if folks can think of any!
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.
Also in hindisght I realize this comment is hilarious in light of #5760 (comment). EuiPopover and EuiContextMenuPanel, name a more iconic duo... for stealing focus from one another and then requiring separate workarounds 😂
Preview documentation changes for this PR: https://eui.elastic.co/pr_5784/ |
Preview documentation changes for this PR: https://eui.elastic.co/pr_5784/ |
jenkins test this |
Preview documentation changes for this PR: https://eui.elastic.co/pr_5784/ |
Preview documentation changes for this PR: https://eui.elastic.co/pr_5784/ |
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 had one 👍 comment and one small text suggestion to change. No need for another review. LGTM!
const focusId = useGeneratedHtmlId(); | ||
useEffect(() => { | ||
if (isPopoverOpen) { | ||
document.getElementById(focusId).focus({ preventScroll: true }); |
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.
👍 on the { preventScroll: true }
object here. It's a good UX buffer.
Co-authored-by: Trevor Pierce <[email protected]>
Preview documentation changes for this PR: https://eui.elastic.co/pr_5784/ |
Preview documentation changes for this PR: https://eui.elastic.co/pr_5784/ |
jenkins test this |
Preview documentation changes for this PR: https://eui.elastic.co/pr_5784/ |
I've QA'd all the components listed in the PR description and they're all working either the same as prod or as expected given these changes. Does anyone have any thoughts/more feedback? Should I wait for @zuhairmahd to chime in? |
@constancecchen If you're okay waiting to Monday to merge, that should give Zuhair a chance to weigh in. I feel we're right on point with this solution. |
Absolutely! |
@constancecchen I plan to take a look at it Monday morning my time if not sooner, so it would be great if you could wait til Monday before merging. I'm seven time zones ahead of eastern, so you should have my feedback by morning your time. |
The behavior of the screen reader text being interrupted appears in my testing to happen only with VoiceOver. NVDA and JAWS exhibited different behaviour. Essentially, they read as expected when the focus was moved to the first element, and when it was moved to the parent, they read the entire contents of the popover. |
Thanks Zuhair! If no objection I'll address screen reader keyboard instructions in a follow-up PR, to keep this one contained for easier debugging / identification if something goes awry in the next release/upgrade. I've made a detailed follow-up issue here: #5813 |
Summary
closes #5683
closes #4973
After extensive discussion between several designers/developers, we've decided to introduce a wide-spread breaking change on
EuiPopover
that removes the default behavior of focusing the first tabbable child element within the popover. Instead, the parent panel will receive a the initial focus.Before:
After:
Why is this a better keyboard / screen reader user experience?
You are in a dialogue
screen reader text gets interrupted/hijacked by focus moving from the panel to the first child. Removing this allows theYou are in a dialogue
text to read out fully (including keyboard instructions to close the dialogue).What if a consumer has a very specific scenario where they want to auto-focus a child and know it makes sense?
This is still totally doable/customizable using the
initialFocus
prop. This PR simply changes the default behavior. I've added a new documentation example in this PR to make that option more evident.What does this affect?
Many components, which we should likely do a QA pass on:
EuiInputPopover
(Feel free to add more to this list if I missed anything, and check items off!)
Checklist
- [ ] Checked in both light and dark modes- [ ] Checked in mobile- [ ] Props have proper autodocs and playground toggles- [ ] Checked Code Sandbox works for any docs examples- [ ] Updated the Figma library counterpartor updated **jest andcypress tests**