FrancescoCastaldi commented on PR #44894:
URL: https://github.com/apache/superset/pull/44894#issuecomment-5954331045

   Hi team,
   
   I expanded the initial fix for #44873 into a comprehensive 10-commit 
hardening suite across both `Select` and `AsyncSelect` to ensure robust option 
deduplication, clear visual feedback for newly created options, and strict 
cleanup semantics.
   
   ### Breakdown of the 10 atomic commits:
   
   1. **`refactor(select): extract and harden option equality and lookup 
helpers in utils.tsx`**
      - Hardened `isEqual`, `getOption`, and `hasOption` to support both string 
and numeric lookups with whitespace trimming.
      - Introduced `isNewOption(option)` helper and added unit test coverage in 
`utils.test.ts`.
   
   2. **`fix(select): drop optimistic new option when fetched options match 
label in AsyncSelect`**
      - In `AsyncSelect`, filtered out optimistic `isNewOption` entries in both 
`mergeData` and `fetchPage` (page 0) whenever server results contain matching 
labels or values, resolving the duplicate row bug on Explore save.
   
   3. **`test(select): add regression tests for optimistic option deduplication 
in AsyncSelect`**
      - Added regression unit tests in `AsyncSelect.test.tsx` verifying that 
optimistic entries are dropped when search responses or paginated pages contain 
matching labels.
   
   4. **`fix(select): align option deduplication and temporary option cleanup 
in Select`**
      - Aligned synchronous `Select.tsx` with `AsyncSelect.tsx`, ensuring 
`handleOnSearch` checks against both loaded and initial options before 
generating temporary custom entries.
   
   5. **`test(select): add test coverage for new option deduplication in 
Select`**
      - Added unit test in `Select.test.tsx` to verify that typing an existing 
option title never creates a duplicate optimistic row.
   
   6. **`feat(select): visually distinguish optimistic new options with a 
subtle badge`**
      - Added `StyledNewOptionBadge` rendering a subtle `[new]` tag in 
`optionRender` for optimistic custom options in both Select and AsyncSelect so 
users can clearly distinguish user-created items from server records.
   
   7. **`fix(select): properly clean up unselected temporary new options on 
deselect and clear`**
      - Ensured unselected optimistic entries are cleanly purged upon `clear` 
and verified that deselected new options match across both label and value 
during removal.
   
   8. **`refactor(select): strengthen TypeScript types and interfaces for 
Select options`**
      - Added explicit `isNewOption?: boolean` typing and JSDoc documentation 
to `CustomLabeledValue` in `types.ts`.
   
   9. **`test(select): add comprehensive edge-case tests for tokenization, 
paste, and search clearing`**
      - Added unit tests for paste deduplication (when pasted items contain 
both existing and new values) and state resets on `clearAll`.
   
   10. **`docs(select): update Storybook stories and documentation for 
allowNewOptions behavior`**
       - Added interactive `WithAllowNewOptions` Storybook stories for both 
`Select` and `AsyncSelect`.
   
   ### Quality & Evidence
   - Audited across all 13 files in 
`packages/superset-ui-core/src/components/Select` using `oxlint` (0 errors) and 
`oxfmt` (100% compliant).
   - All unit and regression tests pass cleanly.
   


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