Expose FocusableProvider in `react-aria`
๐ Feature Request
Expose FocusableProvider from react-aria
๐ค Expected Behavior
Have the ability to inject custom dom attributes into focusable elements
๐ฏ Current Behavior
public useFocusable uses context to inject dom attributes, but the provider is not exposed to the public
๐ Possible Solution
Export FocusableProvider the same way useFocusable is
๐ฆ Context
I'm working on a Tooltip component and I noticed spectrum uses FocusableProvider to implement a nice API where props are automatically injected. I want to do the same. Right now I'm using @react-aria/focus to do that, but I think that should be part of react-aria package itself
๐ป Examples
Example usage in react-spectrum
๐งข Your Company/Team
Chili Piper
We are fine exposing this provider, we'll need docs + additional guardrails to prevent abuse of it so people don't use it to pass any arbitrary attribute to an element.
What guardrails do you have in mind? I can work on it if you elaborate and point me in the right direction with docs
The guardrails would be something along these lines I imagine:
FocusableProvidercurrently accepts all DOMAttributes and passes it down the context. This feels a bit too wide especially since the component consuming the context may only accept a certain attributes. Perhaps something docs should cover?useFocusablecould use some checks to make sure a element is actually focusable/interactive
Hi, I'd like to pick this up if it is still available. I read the previous attempts in #10637 and #10692, including the clarification that the existing provider validation means an additional check in useFocusableContext is unnecessary. I'd keep the change focused on the public export, documentation of the supported attributes and intended usage, and relevant behaviour coverage. Are either of the previous contributors planning to resume, or would a fresh PR be welcome?