-
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
Exposed close
function on Popover
#12341
Exposed close
function on Popover
#12341
Conversation
describe('close', () => { | ||
it('exposes a function that closes the popover & focuses the activator by default', () => { | ||
const activatorId = 'focus-target'; | ||
let popoverRef: React.RefObject<PopoverPublicAPI> | null = 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 pattern is what's used above to test the other function in the imperative handle
@kellydanma @zaquille-oneil Before I reach out to Polaris for a review, what do you think about the approach? |
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.
✅ Approach looks good to me! Seems like a much better way to manage focus than the approach in https://github.com/Shopify/web/pull/131141; I'm going to close my PR and wait for the changes in Polaris to ship before resolving the bug. 😸
LGTM |
/snapit |
🫰✨ Thanks @zaquille-oneil! Your snapshot has been published to npm. Test the snapshot by updating your |
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 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>
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.
(Deleted comment)
WHY are these changes introduced?
Fixes #12336
Fixes #12249
WHAT is this pull request doing?
This PR exposes a
close
function on popovers imperative handle to handle accessibility when closing the popover from an outside source.WHY did you take this approach?
Originally I thought about using an effect to watch the active status, and automatically manage focus when the popover is closed. However, we can't guarantee that the user will always want popover to manage focus. Perhaps, they'll self manage focus to another area of the page, or navigate entirely.
Exposing a
close
function allows us to:Giphy
Monosnap.screencast.2024-07-04.17-52-19.mp4
How to 🎩
Playground code
🎩 checklist
README.md
with documentation changes