From c9f3696bd62e312d4cb53c9f40b0c69645e075dc Mon Sep 17 00:00:00 2001 From: Gaurav Dubey Date: Mon, 20 Jul 2026 02:22:21 +0530 Subject: [PATCH] fix(select): exclude null-valued options from "Select all" count The multi-select "Select all (N)" badge counted every visible option, but handleSelectAll skips options with a falsy value (e.g. the option whose value is null). As a result the badge could read "Select all (3)" while clicking it only selected the two real values, overstating what Select All does. Align the bulkSelectCounts.selectable accumulator with handleSelectAll by applying the same option.value guard, so the count reflects the options that are actually bulk-selectable. Selection behavior is unchanged; only the misleading count is corrected. The deselectable branch is left as-is because handleDeselectAll does clear a selected null option. Fixes #40228 --- .../src/components/Select/Select.test.tsx | 29 +++++++++++++++++++ .../src/components/Select/Select.tsx | 5 ++++ 2 files changed, 34 insertions(+) diff --git a/superset-frontend/packages/superset-ui-core/src/components/Select/Select.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/Select/Select.test.tsx index 08a8fb7c345f..65a60ae8446d 100644 --- a/superset-frontend/packages/superset-ui-core/src/components/Select/Select.test.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/Select/Select.test.tsx @@ -945,6 +945,35 @@ test('do not count unselected disabled options in "Select all"', async () => { ).toBeInTheDocument(); }); +test('"Select all" does not count null-valued options', async () => { + // A falsy-valued option (e.g. , value: null) is skipped by + // handleSelectAll, so it must not be counted in the "Select all" badge or + // the count overstates the selection. Regression test for #40228. Uses a + // local options array to stay isolated from tests that mutate OPTIONS. + const localOptions = [ + { label: 'Alpha', value: 1 }, + { label: 'Bravo', value: 2 }, + ]; + render( + ); await open(); diff --git a/superset-frontend/packages/superset-ui-core/src/components/Select/Select.tsx b/superset-frontend/packages/superset-ui-core/src/components/Select/Select.tsx index bc7578fc8649..9eee3a758b2f 100644 --- a/superset-frontend/packages/superset-ui-core/src/components/Select/Select.tsx +++ b/superset-frontend/packages/superset-ui-core/src/components/Select/Select.tsx @@ -311,7 +311,12 @@ const Select = forwardRef( const isDisabled = option.disabled; const isNew = option.isNewOption; + // Mirror handleSelectAll, which skips falsy-valued options (e.g. the + // option whose value is null): they are not bulk-selectable, + // so counting them here makes the "Select all" badge overstate what + // gets selected. if ( + option.value && (!isDisabled || isSelected) && ((isNew && isSelected) || !isNew) ) {