-
Notifications
You must be signed in to change notification settings - Fork 840
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
Shift focus to accordion content when expanded #4442
Shift focus to accordion content when expanded #4442
Conversation
Preview documentation changes for this PR: https://eui.elastic.co/pr_4442/ |
We don't generally put a focus ring over non-interactive content so I'm ok to ship this as is and revisit the idea of a focus ring later. (Popovers and modals, as an example, shift focus to their container when they open but have no focus ring.) The focus ring would certainly be a welcome addition but it would be good to keep it consistent with everything else too... |
🤔 So what happens if there is interactive content within the accordion content? Should it still be focusing the whole container or shift focus to the first focusable element. Perhaps controlled with a prop similar to the EuiPopover? As for focus rings, no let's not add any forced focus rings to non-interactive elements. 😄 |
Michail answered this in the issue, #4224 (comment), saying it should always move to the container.
I'll remove the focus ring 👍 |
Preview documentation changes for this PR: https://eui.elastic.co/pr_4442/ |
It's not really a problem (and that's where I was going to leave it at) but your question did make do some more digging and we can do better! TL;DR if we add a But what's the full story?First, to be upfront, moving focus actually isn't the "default" recommendation. Often for this pattern, you'll leave focus on the button. But our auditor recommended that we do it and I agreed largely because of the amount of stuff that's on our typical pages and because this is such a generic component. This means that we don't know what sort of stuff is going to be thrown in the button trigger and we don't know in what context this will show up in. So by moving focus we're able to be super explicit to our end user in terms of "here is the thing that happened." So, with that all as a preamble, we're looking at a component that has some similarities to popovers/modals/flyouts/etc. Looking at those as another situation where we move focus around, adding the |
Co-authored-by: Michail Yasonik <michail@yasonik.com>
Preview documentation changes for this PR: https://eui.elastic.co/pr_4442/ |
Preview documentation changes for this PR: https://eui.elastic.co/pr_4442/ |
network flake - jenkins test this |
Preview documentation changes for this PR: https://eui.elastic.co/pr_4442/ |
There's a weird focus issue happening that may or may not be amsterdam specific, where sometimes the content receives a focus ring. Looking into this |
Potential solutions for the amsterdam theme + focus ring + accordion interaction, I don't have any preference and will implement whatever @cchaos and @myasonik say
|
So to clarify on the interaction being specified, it's when the accordion being opened is triggered by pressing space/enter. Then the focus shifts to the accordion content and the focus ring is visible. This is actually working as intended because the interaction was triggered by a keyboard interaction and not the mouse. So when just using the mouse to open/close the accordion, you don't see the focus ring. 👍 |
Ship it as is and we can always revisit if something starts to feel off about this. There aren't any consumer changes to this so it should be pretty low risk to iterate on. |
Summary
Closes #4224 by adding a
tabIndex={-1}
to the accordion's children wrapper and calling.focus()
when it expands.This is a draft because I added
outline: 1px solid blue;
to the focus state on.euiAccordion__childWrapper
and would like help finding the right style to apply.Checklist
[ ] Check against all themes for compatibility in both light and dark modes- [ ] Props have proper autodocs- [ ] Added documentation- [ ] Checked Code Sandbox works for the any docs examples- [ ] A changelog entry exists and is marked appropriately