aminghadersohi opened a new issue, #44873:
URL: https://github.com/apache/superset/issues/44873

   ### Bug description
   
   In the Explore "Save chart" modal, the dashboard select (`AsyncSelect` with 
`allowNewOptions`) can show two rows with the same label when the typed text 
equals an existing dashboard title: the fetched existing dashboard and an 
optimistic "create new" entry. Picking the "create new" row silently creates an 
empty dashboard with a duplicate title and adds the chart to it instead of the 
existing dashboard.
   
   How it happens 
(`superset-frontend/packages/superset-ui-core/src/components/Select/AsyncSelect.tsx`):
   
   1. `handleOnSearch` (debounced) adds an `isNewOption` entry `{ label: typed, 
value: typed }` when no loaded option has that label yet, e.g. the user types 
before the dashboard list has loaded, or the target dashboard is past the first 
page.
   2. When the fetched options arrive, both `mergeData` and the page-0 search 
merge dedupe only by `value`. The new-option value is the typed string and 
dashboard values are numeric ids, so the `isNewOption` entry is never removed 
even though a fetched option now has the same label.
   
   ### Steps to reproduce
   
   1. Have an existing dashboard titled `My dashboard` (more than one page of 
dashboards, or a slow dashboard-list response, makes this easier to hit).
   2. Open a chart in Explore, click Save, choose "Save (Overwrite)".
   3. Quickly type `My dashboard` in the dashboard select.
   4. The dropdown shows two `My dashboard` rows. Select the one that is the 
"create new" entry and save.
   5. A second, empty `My dashboard` is created and the chart is added to it.
   
   Expected: once a fetched option has the same label as an `isNewOption` 
entry, the new-option entry should be dropped (or at least distinguishable).
   
   ### Superset version
   
   master / latest-dev
   
   ### Python version
   
   3.11
   
   ### Node version
   
   Not applicable
   
   ### Browser
   
   Chrome
   
   ### Additional context
   
   Found while fixing a flaky Playwright spec in #44856, where the test typed 
the full title and could select the "create new" row. That PR works around it 
in the test only; the product behavior is unchanged.
   


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