react-spectrum icon indicating copy to clipboard operation
react-spectrum copied to clipboard

<Dialog> render props should include focus states

Open andrew-pledge-io opened this issue 1 year ago โ€ข 0 comments

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

andrew-pledge-io avatar May 14 '24 17:05 andrew-pledge-io