SkinnyPigeon opened a new pull request, #42475: URL: https://github.com/apache/superset/pull/42475
<!--- Please write the PR title following the conventions at https://www.conventionalcommits.org/en/v1.0.0/ Example: fix(dashboard): load charts correctly --> ### SUMMARY The dataset dropdown in the **Create a new chart** screen was not sorted alphabetically by name. Although `/api/v1/dataset/` already returns results ordered by `table_name asc`, `AsyncSelect` re-sorts options internally using `DEFAULT_SORT_COMPARATOR`. Because `DatasetSelectLabel` returns a React node (a `<Tooltip>` wrapper) rather than a plain string, the comparator fell back to `(a.value as number) - (b.value as number)` on string values like `"5__table"`, producing `NaN` and effectively randomising the order. **Fix:** Pass a custom `sortComparator` to the `AsyncSelect` in `ChartCreation` that reads `table_name` from each option object (already present in the options data) and sorts with `localeCompare`. This is a targeted, low-risk change isolated to this one component and does not affect any other `Select` usage across the app. Fixes #42466 ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF **Before:** datasets appear in creation/ID order (e.g. id 2, 5, 4, 3, 6) regardless of name. **After:** datasets appear alphabetically by `table_name`, consistent with the Dataset list view. ### TESTING INSTRUCTIONS 1. Sign in to Superset. 2. Go to **Charts → + Chart**. 3. Open the **Choose a dataset** dropdown. 4. Verify datasets are listed alphabetically by table name. Automated: `npx jest --testPathPatterns="ChartCreation.test"` — all 14 tests pass, including a new test that asserts correct alphabetical DOM order when the API returns datasets with IDs deliberately in non-alphabetical order. ### ADDITIONAL INFORMATION - [x] Has associated issue: #42466 - [ ] 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: [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]
