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) ) {