ARBS-23 opened a new issue, #42466:
URL: https://github.com/apache/superset/issues/42466

   ### Bug description
   
   On the **Create a new chart** screen, the **Choose a dataset** dropdown does 
not list datasets alphabetically by name.
   
   The Dataset list (when creating a dataset) is sorted by name as expected. 
The Create Chart dataset dropdown is not, which makes datasets harder to find 
when there are many.
   
   ### How to reproduce the bug
   
   1. Sign in with any account
   2. Go to **Charts**
   3. Click **+ Chart** to open **Create a new chart**
   4. Open the **Choose a dataset** dropdown
   5. Observe the order of datasets
   
   ### Expected behavior
   
   Datasets in the Create Chart dropdown should be sorted by name (e.g. 
`table_name`), consistent with the Dataset list when creating a dataset.
   
   ### Actual behavior
   
   Datasets appear unordered from a user perspective (effectively by 
creation/ID order rather than name).
   
   ### Root cause (investigation)
   
   Superset’s Create Chart dataset dropdown uses `AsyncSelect`, which sorts 
options by the option **value** (`{id}__table`) when the label is a React node.
   
   Dataset IDs reflect creation order (auto-increment), not `table_name`. So 
even when `/api/v1/dataset/` returns rows ordered by `table_name`, the UI can 
still show them as `2, 3, 4, 5…` by ID instead of alphabetical table name order.
   
   In short: the API can return correctly sorted data, but the frontend 
re-sorts options by value and loses name order.
   
   ### Screenshots/recordings
   
   <img width="1619" height="697" alt="Image" 
src="https://github.com/user-attachments/assets/548bc31b-6ff4-4d9b-9909-376770b2617f";
 />
   
   ```
   {
       "count": 5,
       "description_columns": {},
       "ids": [
           2,
           5,
           4,
           3,
           6
       ],
       "label_columns": {
           "database.database_name": "Database Database Name",
           "datasource_type": "Datasource Type",
           "id": "Id",
           "schema": "Schema",
           "table_name": "Table Name"
       },
       "list_columns": [
           "id",
           "table_name",
           "datasource_type",
           "database.database_name",
           "schema"
       ],
       "list_title": "List Sqla Table",
       "order_columns": [
           "table_name",
           "schema",
           "database.database_name"
       ],
       "result": [
           {
               "database": {
                   "database_name": "fabscape_dev"
               },
               "datasource_type": "table",
               "id": 2,
               "schema": "public",
               "table_name": "0002_amp_chamber"
           },
           {
               "database": {
                   "database_name": "fabscape_dev"
               },
               "datasource_type": "table",
               "id": 5,
               "schema": "public",
               "table_name": "0006_amp_chamber"
           },
           {
               "database": {
                   "database_name": "fabscape_dev"
               },
               "datasource_type": "table",
               "id": 4,
               "schema": "public",
               "table_name": "0007_amp_chamber"
           },
           {
               "database": {
                   "database_name": "fabscape_dev"
               },
               "datasource_type": "table",
               "id": 3,
               "schema": "public",
               "table_name": "0008_amp_chamber"
           },
           {
               "database": {
                   "database_name": "fabscape_dev"
               },
               "datasource_type": "table",
               "id": 6,
               "schema": "public",
               "table_name": "0009_amp_chamber__amp_pressure__ar_ne_gas__t_f2_c"
           }
       ]
   }
   ```
   
   ### Superset version
   
   6.1.0
   
   ### Python version
   
   3.11
   
   ### Node version
   
   16
   
   ### Browser
   
   Chrome
   
   ### Additional context
   
   - This is a **UX / consistency improvement** (suggestion), not a functional 
failure
   - Dataset creation table list already sorts by name; Create Chart dataset 
dropdown should match that behavior
   - Likely fix area: frontend `AsyncSelect` option sorting when labels are 
React nodes — prefer sorting by label/text (or preserve API order) instead of 
sorting by option value (`{id}__table`)
   - Related endpoint: `/api/v1/dataset/` (can already return rows ordered by 
`table_name`)
   
   ### Checklist
   
   - [x] I have searched Superset docs and Slack and didn't find a solution to 
my problem.
   - [x] I have searched the GitHub issue tracker and didn't find a similar bug 
report.
   - [x] I have checked Superset's logs for errors and if I found a relevant 
Python stacktrace, I included it here as text in the "additional context" 
section.


-- 
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]

Reply via email to