From 69dae31c1b2dd7a491d63b1b075df4ce6b4c7db2 Mon Sep 17 00:00:00 2001 From: Valentin Serra Date: Thu, 15 Feb 2024 02:36:00 +0100 Subject: [PATCH] fix: ensure simpleSelect mouseDown event deactivates normally Closes #1045 --- .../render/components/form-fields/parts/SimpleSelect.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/form-js-viewer/src/render/components/form-fields/parts/SimpleSelect.js b/packages/form-js-viewer/src/render/components/form-fields/parts/SimpleSelect.js index 74b87e7f8..a23008f37 100644 --- a/packages/form-js-viewer/src/render/components/form-fields/parts/SimpleSelect.js +++ b/packages/form-js-viewer/src/render/components/form-fields/parts/SimpleSelect.js @@ -56,7 +56,13 @@ export function SimpleSelect(props) { }, [ disabled, isDropdownExpanded, loadState, readonly, value ]); const onMouseDown = useCallback((e) => { + const input = inputRef.current; + + if (disabled || !input) { + return; + } + setIsDropdownExpanded(!isDropdownExpanded); if (isDropdownExpanded) { @@ -66,7 +72,7 @@ export function SimpleSelect(props) { } e.preventDefault(); - }, [ isDropdownExpanded ]); + }, [ disabled, isDropdownExpanded ]); const initialFocusIndex = useMemo(() => value && findIndex(options, (o) => o.value === value) || 0, [ options, value ]);