yousoph opened a new pull request, #40984:
URL: https://github.com/apache/superset/pull/40984
## Summary
Fixes three compounding bugs that prevented native filter default values
from persisting when typed or pasted (rather than selected from the dropdown)
in a creatable multi-select filter.
**Bug:** A Value (`filter_select`) native filter with **Allow creation of
new values** enabled silently dropped default values that were typed or pasted.
The chips appeared in the config modal but after clicking Save the filter
rendered empty on the dashboard, and reopening the config showed no default
value.
### Fix 1 — `Select.tsx`: trim whitespace from pasted tokens (primary fix)
`"10107, 10121".split(",")` previously produced `["10107", " 10121"]` — the
leading space caused label-match failure against the existing option `{value:
10107, label: "10107"}`, resulting in the value being stored as a new string
literal `" 10121"` rather than the correct matched option value.
```diff
- const array = token ? uniq(pastedText.split(token)) : [pastedText];
+ const array = token
+ ? uniq(pastedText.split(token).map(s => s.trim()).filter(Boolean))
+ : [pastedText.trim()].filter(Boolean);
```
### Fix 2 — `SelectFilterPlugin.tsx`: multi-select typed values in options
(secondary fix)
`!multiSelect` guard prevented typed search terms from appearing as
selectable new options in multi-select filters. Also fixed a mutation bug where
`unshift` was called on the memoized `uniqueOptions` array.
```diff
- if (search && !multiSelect && !hasOption(search, uniqueOptions, true)) {
- uniqueOptions.unshift({ label: search, value: search, isNewOption: true
});
- }
- return uniqueOptions;
+ if (search && !hasOption(search, uniqueOptions, true)) {
+ return [{ label: search, value: search, isNewOption: true },
...uniqueOptions];
+ }
+ return uniqueOptions;
```
### Fix 3 — `SelectFilterPlugin.tsx`: include created values in
`uniqueOptions` (tertiary fix)
`uniqueOptions` was built only from DB data. When `filterState.value`
contained created values not in the dataset, they were absent from `options`
and relied on the Select component's internal `fullSelectOptions` fallback
which could lose them across re-renders.
```diff
+ if (creatable !== false && filterState.value) {
+ const existing = new Set(allOptions);
+ ensureIsArray(filterState.value)
+ .filter(v => v !== null && v !== undefined && !existing.has(v))
+ .forEach(v => {
+ baseOptions.push({ label: String(v), value: String(v), isNewOption:
true });
+ existing.add(v);
+ });
+ }
```
## Test plan
- [ ] Reproduce with Vehicle Sales dataset, `order_number` column — paste
`10107, 10121, 10134, 10145, 10159, 10168, 10180, 10188, 10201, 10211` as
default value, Save, verify filter chips appear on dashboard
- [ ] Verify individually typing and pressing Enter also works for
multi-select creatable filters
- [ ] Verify selecting from dropdown still works correctly
- [ ] Run `jest Select.test.tsx` — new test `'trims whitespace from pasted
comma-separated values'` should pass
- [ ] No regression in single-select creatable filter behavior
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]