react-spectrum
react-spectrum copied to clipboard
<Dialog> render props should include focus states
Provide a general summary of the feature here
<Dialog> renders a <section> element and controls when it is focused.
It would be helpful if the className and children both accepted callbacks that included the focus state of the dialog, e.g. isFocused and isFocusVisible, like other react-aria components.
๐ค Expected Behavior?
children and className should both accept callbacks that receive the focused state.
๐ฏ Current Behavior
<Dialog> render props only include a close callback: https://github.com/adobe/react-spectrum/blob/5cacbdbf88b8c6d7f5d3fb741c2b7ccddf8def7f/packages/react-aria-components/src/Dialog.tsx#L25-L27
Only children accepts a callback. className only accepts strings: https://github.com/adobe/react-spectrum/blob/5cacbdbf88b8c6d7f5d3fb741c2b7ccddf8def7f/packages/react-aria-components/src/Dialog.tsx#L29-L32
๐ Possible Solution
No response
๐ฆ Context
I'm using render props to conditionally apply focus styles in other react-aria components, however I can't do so when using <Dialog>.
I'm currently working around the problem by using native CSS pseudo-classes, which is fine but inconsistent.
๐ป Examples
No response
๐งข Your Company/Team
No response
๐ท Tracking Issue
No response