Skip to content

Commit

Permalink
fix: Select disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
juliajforesti committed Nov 22, 2024
1 parent ce6bb5b commit cdb2af5
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions packages/fuselage/src/components/Select/SelectAria.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ export { Item } from 'react-stately';

export const SelectAria = forwardRef(function SelectAria<T extends object>(
{
disabled,
error,
placeholder,
value,
onChange,
small,
isDisabled: isDisabledProps,
disabled,
...props
}: Omit<AriaSelectProps<T>, 'value' | 'onChange'> & {
error?: string;
Expand All @@ -38,16 +39,22 @@ export const SelectAria = forwardRef(function SelectAria<T extends object>(
} & AllHTMLAttributes<HTMLElement>,
outerRef: Ref<HTMLElement>,
) {
const isDisabled = isDisabledProps || disabled;

const state = useSelectState({
isDisabled: disabled,
isDisabled,
selectedKey: value,
onSelectionChange: onChange,
...props,
});

const { ref, borderBoxSize } = useResizeObserver<any>();

const { triggerProps, valueProps, menuProps } = useSelect(props, state, ref);
const { triggerProps, valueProps, menuProps } = useSelect(
{ isDisabled, ...props },
state,
ref,
);

const { buttonProps } = useButton(triggerProps, ref);

Expand All @@ -59,7 +66,7 @@ export const SelectAria = forwardRef(function SelectAria<T extends object>(
<>
<Box
{...props}
disabled={disabled}
disabled={isDisabled}
rcx-select
{...mergeProps(buttonProps, focusProps)}
is='button'
Expand All @@ -71,7 +78,7 @@ export const SelectAria = forwardRef(function SelectAria<T extends object>(
rcx-input-box--small={small}
className={[
error && 'invalid',
disabled && 'disabled',
isDisabled && 'disabled',
(isFocusVisible || state.isOpen) && 'focus',
]
.filter(Boolean)
Expand Down

0 comments on commit cdb2af5

Please sign in to comment.