Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(rac): Add TooltipWrapper support for Checkbox and Radio #6738

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/react-aria-components/src/Checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
import {AriaCheckboxGroupProps, AriaCheckboxProps, HoverEvents, mergeProps, useCheckbox, useCheckboxGroup, useCheckboxGroupItem, useFocusRing, useHover, VisuallyHidden} from 'react-aria';
import {AriaCheckboxGroupProps, AriaCheckboxProps, HoverEvents, mergeProps, useCheckbox, useCheckboxGroup, useCheckboxGroupItem, useFocusable, useFocusRing, useHover, VisuallyHidden} from 'react-aria';
import {CheckboxContext} from './RSPContexts';
import {CheckboxGroupState, useCheckboxGroupState, useToggleState} from 'react-stately';
import {ContextValue, Provider, RACValidation, RenderProps, SlotProps, useContextProps, useRenderProps, useSlot, useSlottedContext} from './utils';
Expand Down Expand Up @@ -220,13 +220,14 @@ function Checkbox(props: CheckboxProps, ref: ForwardedRef<HTMLLabelElement>) {
isRequired: props.isRequired || false
}
});
let {focusableProps} = useFocusable(props, ref);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is giong to double up focus events, they should already supported on Checkbox through useCheckbox->useToggle?


let DOMProps = filterDOMProps(props);
delete DOMProps.id;

return (
<label
{...mergeProps(DOMProps, labelProps, hoverProps, renderProps)}
{...mergeProps(DOMProps, labelProps, hoverProps, focusableProps, renderProps)}
ref={ref}
slot={props.slot || undefined}
data-selected={isSelected || undefined}
Expand Down
6 changes: 3 additions & 3 deletions packages/react-aria-components/src/RadioGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* governing permissions and limitations under the License.
*/

import {AriaRadioGroupProps, AriaRadioProps, HoverEvents, Orientation, useFocusRing, useHover, useRadio, useRadioGroup, VisuallyHidden} from 'react-aria';
import {AriaRadioGroupProps, AriaRadioProps, HoverEvents, Orientation, useFocusable, useFocusRing, useHover, useRadio, useRadioGroup, VisuallyHidden} from 'react-aria';
import {ContextValue, Provider, RACValidation, removeDataAttributes, RenderProps, SlotProps, useContextProps, useRenderProps, useSlot, useSlottedContext} from './utils';
import {FieldErrorContext} from './FieldError';
import {filterDOMProps, mergeProps, mergeRefs, useObjectRef} from '@react-aria/utils';
Expand Down Expand Up @@ -186,7 +186,7 @@ function Radio(props: RadioProps, ref: ForwardedRef<HTMLLabelElement>) {
}, state, inputRef);
let {isFocused, isFocusVisible, focusProps} = useFocusRing();
let interactionDisabled = isDisabled || state.isReadOnly;

let {focusableProps} = useFocusable(props, ref);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks like this should already be supported as well through useRadio?

let {hoverProps, isHovered} = useHover({
...props,
isDisabled: interactionDisabled
Expand All @@ -213,7 +213,7 @@ function Radio(props: RadioProps, ref: ForwardedRef<HTMLLabelElement>) {

return (
<label
{...mergeProps(DOMProps, labelProps, hoverProps, renderProps)}
{...mergeProps(DOMProps, labelProps, hoverProps, focusableProps, renderProps)}
ref={ref}
data-selected={isSelected || undefined}
data-pressed={isPressed || undefined}
Expand Down