Skip to content

Commit

Permalink
[pickers] Fix clearable behavior when disabled (#10542)
Browse files Browse the repository at this point in the history
  • Loading branch information
noraleonte committed Oct 2, 2023
1 parent 1118b2d commit 725d434
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export const useField = <
error,
clearable,
onClear,
disabled,
...otherForwardedProps
},
fieldValueManager,
Expand Down Expand Up @@ -521,6 +522,7 @@ export const useField = <
return {
placeholder,
autoComplete: 'off',
disabled: Boolean(disabled),
...otherForwardedProps,
value: shouldShowPlaceholder ? '' : valueStr,
inputMode,
Expand All @@ -535,6 +537,6 @@ export const useField = <
onClear: handleClearValue,
error: inputError,
ref: handleRef,
clearable: Boolean(clearable && !areAllSectionsEmpty && !readOnly),
clearable: Boolean(clearable && !areAllSectionsEmpty && !readOnly && !disabled),
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ export interface UseFieldInternalProps<TValue, TDate, TSection extends FieldSect
* @default false
*/
clearable?: boolean;
/**
* If `true`, the component is disabled.
* @default false
*/
disabled?: boolean;
}

export interface FieldRef<TSection extends FieldSection> {
Expand Down Expand Up @@ -159,6 +164,7 @@ export interface UseFieldForwardedProps {
error?: boolean;
onClear?: React.MouseEventHandler;
clearable?: boolean;
disabled?: boolean;
}

export type UseFieldResponse<TForwardedProps extends UseFieldForwardedProps> = Omit<
Expand Down

0 comments on commit 725d434

Please sign in to comment.