-
Notifications
You must be signed in to change notification settings - Fork 841
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] Fix popover returning focus to correct element #4071
[EuiPopover] Fix popover returning focus to correct element #4071
Conversation
Show popover | ||
</EuiButton> | ||
); | ||
const [openPopover, setOpenPopover] = useState(null); |
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 change is temporary, for testing
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.
Don't forget to revert this before merging. 😜
Seems like a good time to just remove the animation. We've been fighting it for awhile. If we can't get around it, I think we should be ok removing that as a blocker. My guess is we'll still have an issue, now with shadows "bouncing" in the animation, so I'd still look into the root. |
I disagree that this is a good time/good reason. We rely on this animation in other buttons especially EuiButtonIcon for hover states. I don't want to block the fix for popovers while we investigate all the uses of translate hover state. We do have a specific discuss issue in #2184 for this and should probably be visited via Amsterdam. I can look into the cause for the double-animation but it might be ok to ship with this tiny regression for now. |
I'll move forward with this PR on Monday (with the importance on the focus bug, would like to include it in the next release) - if someone can take a look into the animation before then that'd be great, otherwise we can try to re-prioritize #2184 [working through the lint issues, some tests, and other issues now] |
The focus behavior (aside from the animation) on this one has gotten really funky. Just play around with the "Anchor position" example which "toggles" the popover and you'll see 3 major things.
Happy to zoom about or record these for clarification. I think it's best to finalize the interaction and focus behaviors (JS) before trying to look at the anim bug because they could be related. |
6a44e12
to
87eb56a
Compare
Preview documentation changes for this PR: https://eui.elastic.co/pr_4071/ |
I am aware of and working on one last issue that this change has created. |
Preview documentation changes for this PR: https://eui.elastic.co/pr_4071/ |
@thompsongl @cchaos this is ready for a full review - no rush! |
Preview documentation changes for this PR: https://eui.elastic.co/pr_4071/ |
We still have a bit of a jumpy screen when closing the popover. Here's a video: https://share.getcloudapp.com/DOu9Nvq1 What's happening is I open a popover and then scroll so that it is out of view, when I then click anywhere on the page, it scrolls back up to the original popover's trigger. BUT, if I then tab, the next focusable element is after where I had clicked to dismiss the popover (basically then shooting back down the page). So essentially if a popover is still open but not visible in the viewport, clicking anywhere will force the window to put that old trigger button back into view even though it's not the currently focused element. |
@cchaos pushed a fix for jumping back to the anchor when it is re-focused. The fix - which relies on passing a |
Preview documentation changes for this PR: https://eui.elastic.co/pr_4071/ |
This appears to be an improvement overall 🎉
|
57abce2
to
6d6e1be
Compare
Force pushed after rebasing on master, only new commit since last comment is Address unintentional changes to flyouts & color picker 6d6e1be
I changed EuiFlyout's
Greg contributed the fix for this, making color picker explicitly decide where focus should go when the picker pops up. |
Preview documentation changes for this PR: https://eui.elastic.co/pr_4071/ |
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 changes look good; very happy to see focus_trap simplified 🎉
Manually tested a bunch of docs examples and didn't see any regressions aside from the noted button double-animation.
Don't forget a changelog entry
Show popover | ||
</EuiButton> | ||
); | ||
const [openPopover, setOpenPopover] = useState(null); |
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.
Don't forget to revert this before merging. 😜
Preview documentation changes for this PR: https://eui.elastic.co/pr_4071/ |
Preview documentation changes for this PR: https://eui.elastic.co/pr_4071/ |
…4071) * Move onclickoutside / onescape handling to focus-lock lib itself * Get popover focus return functioning * Fix lint issues & snapshots, re-enable clickOutsideDisables prop for EuiFocusTrap * fix popover re-toggling when clicking its anchor * Re-enable popover outside click and escape key detection when ownFocus is false * Only call popover's closePopover callback when it is open * Don't scroll back to a popover anchor when the popover closes * Address unintentional changes to flyouts & color picker * changelog * revert changes to popover example, which had been made to augment testing * Fix flyout's snapshot tests
Summary
Fixes #4003 and fixes #4107
I've removed a lot of logic from EuiPopover, as it has been duplicated by the stack of focus lock libraries used by the popovers.
This has apparently introduced visual issue (or at least exasperated an existing one) where clicking on a popover anchor button often causes that button to move a lot.
Checklist
- [ ] Check against all themes for compatibility in both light and dark modes- [ ] Checked in mobile- [ ] Props have proper autodocs- [ ] Added documentation- [ ] Added or updated jest tests