Provide a general summary of the feature here
Currently CheckboxFieldProps["inputRef"] has type RefObject<HTMLInputElement | null>, which means that ref callbacks cannot be used. However, it should be fine to pass an arbitrary Ref<HTMLInputElement | null>, as ultimately it only gets consumed inside useCheckboxAria here, and mergeRefs accepts Array<Ref<T> | MutableRefObject<T> | null | undefined>.
Therefore, implementing this change should be as simple as relaxing the type in the prop interface, no code changes required.
🤔 Expected Behavior?
I should be able to pass a ref object or a ref callback to inputRef when creating a CheckboxField. If a ref callback is passed, it should behave as if passed to a regular input JSX element - receiving the input node on component mount and running any returned cleanup function on unmount.
😯 Current Behavior
The types claim can only pass a RefObject to inputRef. However, unsafely casing a ref callback to a ref object should work with the code as-is today (though this relies on assumptions about the implementation details that may break without warning, hence is not a good idea).
💁 Possible Solution
Change the type from RefObject to Ref.
🔦 Context
We are using the same pattern that ref callbacks were designed to improve - effect synchronization with dom node lifecycle. Our current workaround uses useRef + useEffect but this is less reliable, because there is no synchronization between when the ref gets assigned and when the effect fires.
💻 Examples
No response
🧢 Your Company/Team
No response
🕷 Tracking Issue
No response
Provide a general summary of the feature here
Currently
CheckboxFieldProps["inputRef"]has typeRefObject<HTMLInputElement | null>, which means that ref callbacks cannot be used. However, it should be fine to pass an arbitraryRef<HTMLInputElement | null>, as ultimately it only gets consumed insideuseCheckboxAriahere, andmergeRefsacceptsArray<Ref<T> | MutableRefObject<T> | null | undefined>.Therefore, implementing this change should be as simple as relaxing the type in the prop interface, no code changes required.
🤔 Expected Behavior?
I should be able to pass a ref object or a ref callback to
inputRefwhen creating aCheckboxField. If a ref callback is passed, it should behave as if passed to a regularinputJSX element - receiving the input node on component mount and running any returned cleanup function on unmount.😯 Current Behavior
The types claim can only pass a
RefObjecttoinputRef. However, unsafely casing a ref callback to a ref object should work with the code as-is today (though this relies on assumptions about the implementation details that may break without warning, hence is not a good idea).💁 Possible Solution
Change the type from
RefObjecttoRef.🔦 Context
We are using the same pattern that ref callbacks were designed to improve - effect synchronization with dom node lifecycle. Our current workaround uses
useRef+useEffectbut this is less reliable, because there is no synchronization between when the ref gets assigned and when the effect fires.💻 Examples
No response
🧢 Your Company/Team
No response
🕷 Tracking Issue
No response