From cdb2af5775246f49db7f7bbcaa1634a983e4952d Mon Sep 17 00:00:00 2001 From: juliajforesti Date: Fri, 22 Nov 2024 18:42:22 -0300 Subject: [PATCH] fix: `Select` disabled --- .../src/components/Select/SelectAria.tsx | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/packages/fuselage/src/components/Select/SelectAria.tsx b/packages/fuselage/src/components/Select/SelectAria.tsx index bb42dc0a5b..6b98aa2c6a 100644 --- a/packages/fuselage/src/components/Select/SelectAria.tsx +++ b/packages/fuselage/src/components/Select/SelectAria.tsx @@ -22,12 +22,13 @@ export { Item } from 'react-stately'; export const SelectAria = forwardRef(function SelectAria( { - disabled, error, placeholder, value, onChange, small, + isDisabled: isDisabledProps, + disabled, ...props }: Omit, 'value' | 'onChange'> & { error?: string; @@ -38,8 +39,10 @@ export const SelectAria = forwardRef(function SelectAria( } & AllHTMLAttributes, outerRef: Ref, ) { + const isDisabled = isDisabledProps || disabled; + const state = useSelectState({ - isDisabled: disabled, + isDisabled, selectedKey: value, onSelectionChange: onChange, ...props, @@ -47,7 +50,11 @@ export const SelectAria = forwardRef(function SelectAria( const { ref, borderBoxSize } = useResizeObserver(); - const { triggerProps, valueProps, menuProps } = useSelect(props, state, ref); + const { triggerProps, valueProps, menuProps } = useSelect( + { isDisabled, ...props }, + state, + ref, + ); const { buttonProps } = useButton(triggerProps, ref); @@ -59,7 +66,7 @@ export const SelectAria = forwardRef(function SelectAria( <> ( rcx-input-box--small={small} className={[ error && 'invalid', - disabled && 'disabled', + isDisabled && 'disabled', (isFocusVisible || state.isOpen) && 'focus', ] .filter(Boolean)