From 0708f780e54b7fc6b85a83aacae28a6c83f8809b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AB=98=E8=89=B3=E5=85=B5?= Date: Wed, 25 Feb 2026 15:54:26 +0800 Subject: [PATCH 1/3] fix: avoid closing dropdown on input mousedown in multiple mode --- src/SelectInput/index.tsx | 12 +++++++++++- tests/Multiple.test.tsx | 17 +++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/SelectInput/index.tsx b/src/SelectInput/index.tsx index 4c22a537..3fe1d31a 100644 --- a/src/SelectInput/index.tsx +++ b/src/SelectInput/index.tsx @@ -180,13 +180,23 @@ export default React.forwardRef(function Selec // so we need to mark the event directly (event.nativeEvent as any)._ori_target = inputDOM; + const target = event.target as Node | null; + const isClickOnInput = + !!inputDOM && !!target && (target === inputDOM || inputDOM.contains(target)); + if (inputDOM && event.target !== inputDOM && !inputDOM.contains(event.target as Node)) { event.preventDefault(); } // Check if we should prevent closing when clicking on selector // Don't close if: open && not multiple && (combobox mode || showSearch) - const shouldPreventClose = triggerOpen && !multiple && (mode === 'combobox' || showSearch); + const shouldPreventCloseOnSingle = + triggerOpen && !multiple && (mode === 'combobox' || showSearch); + + // Don't close if: open && multiple && click on input + const shouldPreventCloseOnMultipleInput = triggerOpen && !!multiple && isClickOnInput; + + const shouldPreventClose = shouldPreventCloseOnSingle || shouldPreventCloseOnMultipleInput; if (!(event.nativeEvent as any)._select_lazy) { inputRef.current?.focus(); diff --git a/tests/Multiple.test.tsx b/tests/Multiple.test.tsx index 9a2666f9..ee76ebcf 100644 --- a/tests/Multiple.test.tsx +++ b/tests/Multiple.test.tsx @@ -712,5 +712,22 @@ describe('Select.Multiple', () => { toggleOpen(container); expect(container.querySelector('input')).toHaveValue(''); }); + + it('should not close dropdown when mousedown on input in multiple mode (text selection)', () => { + const { container } = render( +