You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "SEPURI-SAI-KRISHNA (via GitHub)" <gi...@apache.org> on 2026/07/25 04:56:23 UTC
[PR] fix(select): rank case-insensitive matches consistently in dropdown search [superset]
SEPURI-SAI-KRISHNA opened a new pull request, #42408:
URL: https://github.com/apache/superset/pull/42408
### SUMMARY
`rankedSearchCompare` is the default sort comparator for every Select and
AsyncSelect in Superset (`DEFAULT_SORT_COMPARATOR` in
`packages/superset-ui-core/src/components/Select/constants.ts`). Its
case-insensitive substring tier had a copy-paste error:
```ts
Number(bLower.includes(searchLower)) - Number(a.includes(searchLower))
// ^ raw `a`, should be `aLower`
```
The left operand is lowercased, the right one is not, so the two sides of the
comparison are not comparable. This has two effects:
1. **The tier is effectively dead.** An option that matches the search only
when case is ignored is not ranked above an option that does not match at
all — the comparison yields 0 and falls through to `localeCompare`.
2. **The comparator is not antisymmetric.** For `a = "zzABCzz"`,
`b = "aaaa"`, `search = "abc"`, both `compare(a, b)` and `compare(b, a)`
return `1`. `Array.prototype.sort` requires a consistent comparator; with
an inconsistent one the resulting order is implementation-defined.
Where this surfaces: `Select` filters options case-insensitively before
sorting (`handleFilterOptionHelper`), and `optionFilterProps` defaults to
`['label', 'value']`, so an option can enter the sorted set by matching on its
`value` while the comparator inspects its `label`. Those options are the ones
misranked.
The fix compares `aLower` against `bLower`, consistent with every other tier
in the chain.
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Not a visual change; the observable difference is ordering. With
`search = "abc"`:
| | `compare("zzABCzz", "aaaa")` | `compare("aaaa", "zzABCzz")` | sorted |
|---|---|---|---|
| before | `1` | `1` | `["aaaa", "zzABCzz"]` |
| after | `-1` | `1` | `["zzABCzz", "aaaa"]` |
### TESTING INSTRUCTIONS
```bash
cd superset-frontend
npm run test -- packages/superset-ui-core/src/utils/rankedSearchCompare.test.ts
```
Two tests are added:
- `ranks a case-insensitive substring match above a non-match`
- `is antisymmetric so Array.prototype.sort stays well defined`
To confirm they are genuine regression tests, revert the one-line change and
re-run — the first fails with `Expected: < 0, Received: 1` and the second with
`Expected: 0, Received: 2`.
Also verified no regressions in the consumers:
```bash
npm run test -- packages/superset-ui-core/src/components/Select packages/superset-ui-core/test/utils
```
### ADDITIONAL INFORMATION
- [ ] Has associated issue:
- [ ] Required feature flags:
- [x] Changes UI
- [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
- [ ] Migration is atomic, supports rollback & is backwards-compatible
- [ ] Confirm DB migration upgrade and downgrade tested
- [ ] Runtime estimates and downtime expectations provided
- [ ] Introduces new feature or API
- [ ] Removes existing feature or API
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(select): rank case-insensitive matches consistently in dropdown search [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas merged PR #42408:
URL: https://github.com/apache/superset/pull/42408
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(select): rank case-insensitive matches consistently in dropdown search [superset]
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #42408:
URL: https://github.com/apache/superset/pull/42408#issuecomment-5077099217
## [Codecov](https://app.codecov.io/gh/apache/superset/pull/42408?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 65.24%. Comparing base ([`8c37d62`](https://app.codecov.io/gh/apache/superset/commit/8c37d627aa9c8351e7e60611cd3e1219495bb830?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`7862cb4`](https://app.codecov.io/gh/apache/superset/commit/7862cb477562ccb8c8c74031f0c45baa744d7ed6?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## master #42408 +/- ##
=======================================
Coverage 65.24% 65.24%
=======================================
Files 2795 2795
Lines 157643 157643
Branches 36061 36061
=======================================
Hits 102853 102853
Misses 52814 52814
Partials 1976 1976
```
| [Flag](https://app.codecov.io/gh/apache/superset/pull/42408/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [javascript](https://app.codecov.io/gh/apache/superset/pull/42408/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `71.27% <100.00%> (ø)` | |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
</details>
[:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/superset/pull/42408?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(select): rank case-insensitive matches consistently in dropdown search [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #42408:
URL: https://github.com/apache/superset/pull/42408#issuecomment-5077022279
AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(select): rank case-insensitive matches consistently in dropdown search [superset]
Posted by "hainenber (via GitHub)" <gi...@apache.org>.
hainenber commented on PR #42408:
URL: https://github.com/apache/superset/pull/42408#issuecomment-5078935114
Thanks for the fix, @SEPURI-SAI-KRISHNA. By all means, this makes sense for the search ranking logic. If there are no concern from @michael-s-molina, this is merge-able ;)
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org