-
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
[PageActions] Add ReactNode as an accepted primaryAction prop value for customizability #5946
Conversation
/snapshot-release |
size-limit report 📦
|
/snapit |
🤌 ✨ Thanks @alex-page! Your snapshots have been shipped. Test the snapshots by updating your yarn add @shopify/polaris-icons@0.0.0-snapshot-release-20220525204914 yarn add @shopify/polaris@0.0.0-snapshot-release-20220525204914 yarn add @shopify/polaris-tokens@0.0.0-snapshot-release-20220525204914 yarn add @shopify/stylelint-polaris@0.0.0-snapshot-release-20220525204914 |
b0c675f
to
b06e3c5
Compare
/snapit |
1 similar comment
/snapit |
@rmleg there is still an issue with the permissions. Sorry about that. We will get that ironed out. |
🤌 ✨ Thanks @alex-page! Your snapshots have been shipped. Test the snapshots by updating your yarn add @shopify/polaris-icons@0.0.0-snapshot-release-20220525211817 yarn add @shopify/polaris@0.0.0-snapshot-release-20220525211817 yarn add @shopify/polaris-tokens@0.0.0-snapshot-release-20220525211817 yarn add @shopify/stylelint-polaris@0.0.0-snapshot-release-20220525211817 |
/snapit |
🫰✨ Thanks @rmleg! Your snapshots have been published to npm. Test the snapshots by updating your yarn add @shopify/polaris-icons@0.0.0-snapshot-release-20220525220051 yarn add @shopify/polaris@0.0.0-snapshot-release-20220525220051 yarn add @shopify/polaris-tokens@0.0.0-snapshot-release-20220525220051 yarn add @shopify/stylelint-polaris@0.0.0-snapshot-release-20220525220051 |
/snapit |
🫰✨ Thanks @rmleg! Your snapshots have been published to npm. Test the snapshots by updating your yarn add @shopify/polaris-icons@0.0.0-snapshot-release-20220526145039 yarn add @shopify/polaris@0.0.0-snapshot-release-20220526145039 yarn add @shopify/polaris-tokens@0.0.0-snapshot-release-20220526145039 yarn add @shopify/stylelint-polaris@0.0.0-snapshot-release-20220526145039 |
polaris-react/src/components/PageActions/tests/PageActions.test.tsx
Outdated
Show resolved
Hide resolved
93650f9
to
62c3fb6
Compare
WHY are these changes introduced?
This PR is related to recent changes to support passing a
React.ReactNode
to thesecondaryActions
prop of thePageActions
component (and much of this PR's description is plagiarized from that one; thank you @stefanlegg!).Currently
primaryAction
onPageActions
only allows for passing props asDisableableAction & LoadableAction
. This doesn't allow for flexibility and results in accessibility issues in some cases.In cases where the primary action opens a modal, we are unable to move focus back to the button that opened it after the modal is closed. With this change to accept
React.ReactNode
we are better able to support keyboard users through passing an entire modal as the primary action to leverage modal's built-in focus management, or through passing a custom button with a ref to receive the focus.This is also consistent with current behavior of the
Page
component, which can accept aReact.ReactNode
as itsprimaryAction
prop.WHAT is this pull request doing?
This PR maintains the existing
primaryAction
prop, while adding the option to pass aReact.ReactNode
instead for customizability.I've also added a new example to the README for this component, highlighting this new supported prop type by passing in a custom button to
primaryAction
.My new example in storybook
My new example on the style guide site
Tophatted in web
The disabled button to the right has been passed in as a
React.ReactNode
.How to 🎩
Use the Polaris snapshot release with polaris-styleguide (
yarn add @shopify/polaris@0.0.0-snapshot-release-20220525220051
) to verify that the new example displays in the documentation.In storybook, verify that the
PageActions/Page actions with custom primary action
story displays a custom primary action, in this case a "Save" button with a drop-down option to "save as draft".🎩 checklist
README.md
with documentation changes