-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
DisclosureContent
: migrate from reakit
to @ariakit/react
#55639
Conversation
Size Change: -408 B (0%) Total Size: 1.7 MB
ℹ️ View Unchanged
|
9e2732a
to
d9aed65
Compare
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.
I have some concerns regarding keeping the same APIs as before, and whether it's a good idea, considering that the Ariakit API already supports all cases we're adding. I left a few comments to outline those.
In general, I wonder if we should just deprecate the old version and just expose a v2 that solely relies on the Ariakit Disclosure
component family?
* Accessible Disclosure component that controls visibility of a section of | ||
* content. It follows the WAI-ARIA Disclosure Pattern. | ||
* | ||
* @see https://ariakit.org/reference/disclosure-content |
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.
I wonder if we should also reference some more examples that include how the entire disclosure component family works (with the provider, disclosure, and disclosure content). We could link to the examples in the Ariakit docs of course, but it could be useful for someone who needs to understand the whole picture of the Disclosure
component family.
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.
In the light of the approach chosen for this PR, it's probably better not to link to ariakit docs, since DisclosureContent
wouldn't currently have the same public APIs as the ariakit
component.
Hey @tyxla , let me add some extra context around these changes. Markus and I recently discussed how to go about these changes. Markus proposed to have a first PR (this one) where he would try to refactor from If you think that it's better to compound those changes into one PR, I'm happy to go for that approach and to start understanding the best way forward. |
I just thought this step was unnecessary since we'll end up either removing or deprecating this prop or the entire old version of the component anyway, meaning it might be a good time to adopt the complete Ariakit API anyway. The point about speeding up the reakit migration makes sense to me though, so I'm happy to go with that approach. However, to me that only makes sense if we deprecate this component and do a fully new V2 with the new Ariakit API. Is that what you folks had in mind? |
I'm not sure that deprecating the current usage is compatible with the need for removing Given the similar conversation that we had around
Optionally, we could try to see if we can detect when Something like:const DisclosureContent = ( {
// Depretacted reakit props
baseId,
visible,
animated,
animating,
stopAnimation,
// New ariakit props
...props
} ) {
let fallbackReakitStore;
if (
// any of the deprecated props are defined
) {
// Add warning about legacy reakit props being deprecated, and that the component
// may not work as intended. Consumers should migrated to the ariakit APIs.
fallbackReakitStore = Ariakit.useDisclosureStore( {
animated,
open: visible,
} );
}
return <Ariakit.DisclosureContent {...props} store={props.store ?? fallbackReakitStore} />
} @diegohaz what do you think about this approach? |
For this PR, I'd concentrate solely on implementing the API that the old version already supported, maintaining the The decision to rename the prop to |
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.
Thanks for clarifying @ciampo and @diegohaz!
I'm happy with your plan, so marking my comments as resolved.
I've only left open a few comments regarding documentation, but those aren't blockers, so I'm retracting my blocking review.
Happy to leave the final review and approval to @ciampo and/or @diegohaz.
My concerns were addressed in #55639 (comment)
a5bef21
to
5939d4a
Compare
Flaky tests detected in 5939d4a. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/6781432800
|
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.
Tests well as per instructions, and code changes LGTM 🚀
Left a few extra comments, feel free to merge once they're addressed.
* Accessible Disclosure component that controls visibility of a section of | ||
* content. It follows the WAI-ARIA Disclosure Pattern. | ||
* | ||
* @see https://ariakit.org/reference/disclosure-content |
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.
In the light of the approach chosen for this PR, it's probably better not to link to ariakit docs, since DisclosureContent
wouldn't currently have the same public APIs as the ariakit
component.
5939d4a
to
f59bcf3
Compare
Nice! As a follow-up, we can now look into introducing the full suite of |
What?
DisclosureContent
fromreakit
toariakit
Why?
Part of #53278
As stated in the linked issue Reakit does not explicitly support React 18 (causing peer dependency warnings) and Reakit has already been succeeded by Ariakit, so it will not receive any more updates.
How?
Switch out the Reakit dependency for Ariakit. We also have to create a small wrapper to maintain the existing API of the component.
Testing Instructions
This component doesn't come with a story and is used in only one place:
npm run dev
andnpm run wp-env start
localhost:8888
and activate a theme which supports widgetsAppearance
>Widgets
and verify toggling widget areas still works as expected