From 16025a785ff743cb6bfe9ff544136ac9afe904e4 Mon Sep 17 00:00:00 2001 From: Ugo Stephant Date: Thu, 29 Sep 2022 09:47:27 +0200 Subject: [PATCH] fix(react): prevent clearing selectfield when disabled --- packages/react/lib/SelectField/index.js | 3 +- .../react/lib/SelectField/index.stories.js | 10 ++++++ .../react/lib/SelectField/index.test.js.snap | 32 +++++++++++++++---- packages/theme/lib/SelectField.sass | 7 ++++ 4 files changed, 45 insertions(+), 7 deletions(-) diff --git a/packages/react/lib/SelectField/index.js b/packages/react/lib/SelectField/index.js index 052b1ff45..a2ff797e8 100644 --- a/packages/react/lib/SelectField/index.js +++ b/packages/react/lib/SelectField/index.js @@ -158,7 +158,7 @@ const SelectField = forwardRef(({ const onClear = e => { e.stopPropagation(); - if (!clearable) { + if (!clearable || disabled) { return; } @@ -415,6 +415,7 @@ const SelectField = forwardRef(({ onChange={onSearchInputChange} ref={searchInputRef} autoFocus={autoFocus} + disabled={disabled} onFocus={onFocus_} onBlur={onBlur_} onKeyPress={onKeyPress_} diff --git a/packages/react/lib/SelectField/index.stories.js b/packages/react/lib/SelectField/index.stories.js index b08532ec2..7386de834 100644 --- a/packages/react/lib/SelectField/index.stories.js +++ b/packages/react/lib/SelectField/index.stories.js @@ -21,6 +21,16 @@ export const multiple = () => ( /> ); +export const disabled = () => ( + +); + export const asyncSearch = () => ( should render multiple values 1`] = ` Item 1 - + + + + should render multiple values 1`] = ` Item 2 - + + + +