From 1d156df4280f2b85f9fc8390dcd9a61b50d14b0a Mon Sep 17 00:00:00 2001 From: lnuxe Date: Fri, 13 Nov 2026 11:09:20 +0800 Subject: [PATCH 1/2] fix(select): derive the check-all direction from the current selection The check-all option decided its direction from the internal selected state: if (checkAll) { ... trigger: isAllSelected ? 'uncheck' : 'check' } When the caller resets the value from outside, the internal state and the rendered options disagree for one render, so clicking check-all could fire the opposite action - unchecking when everything was already cleared. Compute the direction from the options that are actually rendered and enabled. Verified: - new test fails on the previous implementation (expected [] to deeply equal [ 'apple', 'orange', 'banana' ]) - new test passes with the fix - select: 47 tests pass --- .../__tests__/select-check-all.test.tsx | 53 +++++++++++++++++++ packages/components/select/base/Select.tsx | 10 +++- 2 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 packages/components/select/__tests__/select-check-all.test.tsx diff --git a/packages/components/select/__tests__/select-check-all.test.tsx b/packages/components/select/__tests__/select-check-all.test.tsx new file mode 100644 index 0000000000..2d7fbfc940 --- /dev/null +++ b/packages/components/select/__tests__/select-check-all.test.tsx @@ -0,0 +1,53 @@ +import React from 'react'; +import { fireEvent, render } from '@test/utils'; + +import { Select } from '..'; + +const flush = () => + new Promise((resolve) => { + setTimeout(resolve, 0); + }); + +describe('Select', () => { + describe('scenarios', () => { + describe('check all', () => { + it('re-selects every option after one option is unchecked', async () => { + const options = [ + { label: 'All', checkAll: true }, + { label: 'Apple', value: 'apple' }, + { label: 'Orange', value: 'orange' }, + { label: 'Banana', value: 'banana' }, + ]; + const calls: any[] = []; + const { container } = render( +