Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Duplicated options in Select when using numerical values #24906

Merged

Conversation

michael-s-molina
Copy link
Member

SUMMARY

We noticed that Select options were being duplicated when searching for a value in numerical filters. It turns out that Ant Design Select can't have options with numerical values when mode equals tags. It displays the following warning:

Warning: value of Option should not use number type when mode is tags or combobox

To overcome this limitation, this PR changes the mode to multiple and implement missing features such as allowing new values and copy and paste.

Fixes #24877

TESTING INSTRUCTIONS

I added a test to the component but we need to check the general use of selects in the application because there are wrappers that override the component behavior such as SelectControl and SelectFilterPlugin.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • 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

@codecov
Copy link

codecov bot commented Aug 7, 2023

Codecov Report

Merging #24906 (51a7dbd) into master (aee2695) will increase coverage by 10.38%.
Report is 13 commits behind head on master.
The diff coverage is 74.19%.

❗ Current head 51a7dbd differs from pull request most recent head 1c63c8f. Consider uploading reports for the commit 1c63c8f to get more accurate results

@@             Coverage Diff             @@
##           master   #24906       +/-   ##
===========================================
+ Coverage   58.45%   68.84%   +10.38%     
===========================================
  Files        1906     1906               
  Lines       74141    74144        +3     
  Branches     8208     8207        -1     
===========================================
+ Hits        43337    51041     +7704     
+ Misses      28683    20971     -7712     
- Partials     2121     2132       +11     
Flag Coverage Δ
hive ?
javascript 55.82% <70.37%> (-0.02%) ⬇️
presto ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
...s/legacy-plugin-chart-country-map/src/countries.ts 100.00% <ø> (ø)
...c/features/datasets/AddDataset/LeftPanel/index.tsx 89.47% <ø> (ø)
superset-frontend/src/features/datasets/styles.ts 92.00% <50.00%> (-8.00%) ⬇️
superset-frontend/src/components/Select/Select.tsx 84.65% <69.23%> (-1.14%) ⬇️
...set-frontend/src/components/Select/AsyncSelect.tsx 84.79% <72.72%> (-4.53%) ⬇️
...tend/src/features/datasets/DatasetLayout/index.tsx 100.00% <100.00%> (ø)
superset/config.py 92.20% <100.00%> (+0.58%) ⬆️
superset/security/manager.py 94.43% <100.00%> (+33.95%) ⬆️
superset/utils/core.py 90.39% <100.00%> (+22.64%) ⬆️

... and 291 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@rusackas rusackas added review:checkpoint Last PR reviewed during the daily review standup and removed review:checkpoint Last PR reviewed during the daily review standup labels Aug 7, 2023
@michael-s-molina
Copy link
Member Author

/testenv up

@github-actions
Copy link
Contributor

github-actions bot commented Aug 7, 2023

@michael-s-molina Ephemeral environment spinning up at http://34.221.157.238:8080. Credentials are admin/admin. Please allow several minutes for bootstrapping and startup.

@kgabryje
Copy link
Member

@michael-s-molina Have you considered an alternative approach of stringifying the numeric values when using them as option values and then parsing the numbers in onSelect callback? If it's possible, it could save us some added complexity of the features added for parity with tag mode

expect(options[1]?.textContent).toEqual('CAc');
expect(options[2]?.textContent).toEqual('abac');
expect(options[3]?.textContent).toEqual('Cac');
await waitFor(() => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are all those test changes relevant to the fix or are those just some bycatches?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes are the result of debouncing handleOnSearch.

@michael-s-molina
Copy link
Member Author

michael-s-molina commented Aug 10, 2023

@michael-s-molina Have you considered an alternative approach of stringifying the numeric values when using them as option values and then parsing the numbers in onSelect callback? If it's possible, it could save us some added complexity of the features added for parity with tag mode

I did consider this approach but rejected for the following reasons:

  • It goes against the Typescript definition of the values
  • It has performance implications when dealing with a big number of options
  • Numbers are supported in single and multiple modes.

@kgabryje
Copy link
Member

I did consider this approach but rejected for the following reasons:

  • It goes against the Typescript definition of the values
  • It has performance implications when dealing with a big number of options
  • Numbers are supported in single and multiple modes.

Got it, thanks for explanation 👍

Copy link
Member

@kgabryje kgabryje left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@geido geido left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code LGTM. We will run regression testing on this one to catch any possible side effect. Thanks!

@michael-s-molina michael-s-molina merged commit b621ee9 into apache:master Aug 11, 2023
26 checks passed
@github-actions
Copy link
Contributor

Ephemeral environment shutdown and build artifacts deleted.

@michael-s-molina michael-s-molina added the v3.0 Label added by the release manager to track PRs to be included in the 3.0 branch label Aug 11, 2023
michael-s-molina added a commit that referenced this pull request Aug 14, 2023
@mistercrunch mistercrunch added 🍒 3.0.3 🍒 3.0.4 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 3.1.0 labels Mar 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.1.1 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/L v2.1 v3.0 Label added by the release manager to track PRs to be included in the 3.0 branch 🍒 3.0.0 🍒 3.0.1 🍒 3.0.2 🍒 3.0.3 🍒 3.0.4 🚢 3.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Numeric filters show duplicate values and UI issue when scrolling
6 participants