Closed thexpand closed 4 days ago
I don't see any reason not to do this.
@snowystinger I created a PR (#6459) for this. This is my first one for react-spectrum
, so let me know if something looks awry.
I'd like to request that Hidden
and createHideableComponent
also be exported as part of this effort, for the simplicity of implementation and completeness of feature suite
createHideableComponent
should be added soon https://github.com/adobe/react-spectrum/pull/6640
We still looking into ways to handle the Hidden
component https://github.com/adobe/react-spectrum/pull/6459#issuecomment-2146376427
It should be noted that createHideableComponent is only an optimization and is not required for a functional implementation.
This will also be marked unstable in the upcoming release so it could change at any time.
closing due to #6640
@devongovett It looks like the HiddenContext
was not exported in the new @react-aria/collections
or through react-aria-components
. This means that the HiddenContext
can't be reused as a provider
I'd like to reopen this issue until HiddenContext
is fully exported
Also, it feels a little weird that the whole hidden suite got rolled into collections considering it's used by components like Button
that have no connection with collection at all
What are you trying to do with this? The provider is built into createHidableComponent
, and you can consume it via useIsHidden
. The only use case we have for this is in collections, but again it's just an optimization, not necessary for correctness.
If I want to build a component that implements the HiddenContext.Provider
and controls whether a descendant is hidden or not. As you have it now, it's only possible to consume the HiddenContext
which is implemented by RAC/Collections. I'd like to be able to create my own components that control that state.
It'd also be helpful to have your Hidden
component exported
I swear that you had a RAC with <Provider values={[[HiddenContext, ...]]}>
implemented somewhere, but now I can't find it. Maybe it got refactored?
Yeah that all got moved into the new CollectionBuilder
component that we're using everywhere now so you don't need to worry about setting the hidden context or configuring SSR manually anymore. See here for example (will update the docs eventually). https://github.com/adobe/react-spectrum/blob/4fc70174ac35a5ebf06379f5cafaf943519a1eac/packages/react-aria-components/src/Select.tsx#L87-L91
But if I'm building something that isn't a collection and I want to use HiddenContext
or Hidden
?
Like what? It wasn't really intended as a general purpose thing, it's just an implementation detail. Can't you use your own context if you are doing something other than a collection?
Provide your feedback here.
I want to build a select field using the Select component. However, I have my own popover component that I want to use instead of the one from React Aria, but can't because I can't use
HiddenContext
, as it's not exported but it's required bySelect
for everything to work properly.🔦 Context
I want to build a similar logic like this in my own Popover component: https://github.com/adobe/react-spectrum/blob/2bda4c971dd557be7ecc44614569a8281e6cb6dd/packages/react-aria-components/src/Popover.tsx#L87-L100
Can we just have this context exported, so that we can use it in our own (user land) components if needed?
💻 Code Sample
No response
Version
react-aria-components@1.2.1
What browsers are you seeing the problem on?
Firefox, Chrome, Safari, Microsoft Edge
If other, please specify
No response
What operating system are you using?
macOS