From b50f9cf0e25580b0e93a21b7b997e8c8f3966bea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=AC=A2?= Date: Wed, 24 Jun 2026 15:28:08 +0800 Subject: [PATCH 1/4] fix: should not create tag when input matches disabled option in tags mode fix #30878 --- src/Select.tsx | 7 +++++++ tests/Tags.test.tsx | 22 ++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/src/Select.tsx b/src/Select.tsx index 26fbbd000..2deb48f13 100644 --- a/src/Select.tsx +++ b/src/Select.tsx @@ -630,6 +630,13 @@ const Select = React.forwardRef([...rawValues, formatted])); triggerChange(newRawValues); triggerSelect(formatted, true); diff --git a/tests/Tags.test.tsx b/tests/Tags.test.tsx index 74da89955..5114434df 100644 --- a/tests/Tags.test.tsx +++ b/tests/Tags.test.tsx @@ -59,6 +59,28 @@ describe('Select.Tags', () => { expect(onChange).toHaveBeenCalledWith(['foo'], [{}]); }); + // https://github.com/ant-design/ant-design/issues/30878 + it('should not create tag when input matches disabled option on blur', () => { + const onChange = jest.fn(); + const { container } = render( + false} + />, + ); + + fireEvent.change(container.querySelector('input'), { target: { value: 'orange' } }); + fireEvent.keyDown(container.querySelector('input'), { key: 'Enter' }); + + jest.runAllTimers(); + // Should not create tag or show temp option in dropdown + expect(findSelection(container).textContent).toBe(''); + expect(onChange).not.toHaveBeenCalled(); + }); + it('tokenize input', () => { const handleChange = jest.fn(); const handleSelect = jest.fn(); @@ -104,6 +130,28 @@ describe('Select.Tags', () => { expectOpen(container, false); }); + // https://github.com/ant-design/ant-design/issues/30878 + it('should not create tag when token matches disabled option with tokenSeparators', () => { + const handleChange = jest.fn(); + const { container } = render( +