-
Notifications
You must be signed in to change notification settings - Fork 1.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
Updated tab item focus to wait for the next frame #12335
Conversation
/snapit |
🫰✨ Thanks @AndrewMusgrave! Your snapshot has been published to npm. Test the snapshot by updating your "@shopify/polaris": "0.0.0-snapshot-20240703204424" |
focused | ||
) { | ||
focusedNode.current.focus(); | ||
const focusTarget = focusedNode.current; |
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 is needed to keep the variable within scope for the RAF
const focusTarget = focusedNode.current; | ||
|
||
if (focusTarget && focusTarget instanceof HTMLElement && focused) { | ||
requestAnimationFrame(() => { |
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.
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.
Tophat and code LGTM! 🎩✨ Thanks for much for this fix Andrew! Let me just tag one more Polaris dev for a second review since Chloe is out for a bit.
While tophatting I noticed some odd behavior with how the focus styles are applied. We're using the focus visible selector, but manually sending focus. This is causing the browser to sometimes not display the focus ring - I noticed it the most on firefox.
I wasn't able to reproduce this while tophatting 🤔 Would you mind adding a video to a new issue so I can try to reproduce this? And was this happening prior to your fix? If so, we can keep this separate from these changes.
@lgriffee I wish I did take a video, I'm having trouble reproducing it again! However, it was on main. The core of the issue was we're manually setting focus, and whatever heuristic the |
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @shopify/polaris@13.7.0 ### Minor Changes - [#12341](#12341) [`f6728a410`](f6728a4) Thanks [@AndrewMusgrave](https://github.com/AndrewMusgrave)! - Exposed a `close` function on popovers imperative handle ### Patch Changes - [#12335](#12335) [`d71b3a282`](d71b3a2) Thanks [@AndrewMusgrave](https://github.com/AndrewMusgrave)! - Fixed `Tabs` automatically closing when opened in a scrolled position - Updated dependencies \[[`b4cbdefd4`](b4cbdef)]: - @shopify/polaris-tokens@9.3.0 ## @shopify/polaris-tokens@9.3.0 ### Minor Changes - [#12398](#12398) [`b4cbdefd4`](b4cbdef) Thanks [@alex-page](https://github.com/alex-page)! - Update the green and red token values ## @shopify/polaris-migrator@1.0.4 ### Patch Changes - Updated dependencies \[[`b4cbdefd4`](b4cbdef)]: - @shopify/polaris-tokens@9.3.0 - @shopify/stylelint-polaris@16.0.4 ## @shopify/stylelint-polaris@16.0.4 ### Patch Changes - Updated dependencies \[[`b4cbdefd4`](b4cbdef)]: - @shopify/polaris-tokens@9.3.0 ## polaris-for-vscode@1.0.4 ### Patch Changes - Updated dependencies \[[`b4cbdefd4`](b4cbdef)]: - @shopify/polaris-tokens@9.3.0 ## polaris.shopify.com@1.0.10 ### Patch Changes - Updated dependencies \[[`b4cbdefd4`](b4cbdef), [`d71b3a282`](d71b3a2), [`f6728a410`](f6728a4)]: - @shopify/polaris-tokens@9.3.0 - @shopify/polaris@13.7.0 Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
WHY are these changes introduced?
Fixes #11829
WHAT is this pull request doing?
Using the same pattern as popover overlay to delay focusing to the next frame (for measuring/positioning)
Giphy
Before
Monosnap.screencast.2024-07-03.16-41-53.mp4
After
Monosnap.screencast.2024-07-03.16-41-16.mp4
How to 🎩
Playground code ⬇️
Notes
While tophatting I noticed some odd behavior with how the focus styles are applied. We're using the focus visible selector, but manually sending focus. This is causing the browser to sometimes not display the focus ring - I noticed it the most on firefox.
🎩 checklist
README.md
with documentation changes