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(SelectControl): select zero value #26353

Merged
merged 1 commit into from
Jan 3, 2024

Conversation

rekilina
Copy link
Contributor

SUMMARY

If SelectControl has options with numeric values, then the value 0 can be selected.
In this case, if defaultValue is not set or it is set to undefined, then currentValue will be set to undefined instead of 0.
This fix allows correctly save SelectControl with selected option, which value equals to 0, when the default value is undefined.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TESTING INSTRUCTIONS

  1. Create SelectControl instance in the controlPanel and set choices with numeric value:
    [[0, "label_1"], [1, "label_2"]]
    Don't specify default value or set default value to undefined.
  2. Select option with value 0 and save chart.
  3. Reload page and check, whether the SelectControl has selected value.

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

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Congrats on making your first PR and thank you for contributing to Superset! 🎉 ❤️

We hope to see you in our Slack community too! Not signed up? Use our Slack App to self-register.

Copy link

codecov bot commented Dec 25, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (b6d433d) 69.17% compared to head (8e5fc3c) 69.17%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #26353   +/-   ##
=======================================
  Coverage   69.17%   69.17%           
=======================================
  Files        1945     1945           
  Lines       75979    75979           
  Branches     8476     8476           
=======================================
  Hits        52562    52562           
  Misses      21227    21227           
  Partials     2190     2190           
Flag Coverage Δ
javascript 56.52% <100.00%> (ø)

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@villebro villebro left a comment

Choose a reason for hiding this comment

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

Great catch! I would have asked if you could add a test, but I see this is one of those old non-TS pieces of code that likely doesn't have good tests to begin with. So LGTM.

@villebro
Copy link
Member

@rekilina I didn't have my laptop handy yesterday, but I noticed now that there's SelectControl.test.jsx where you should be able to add a test for this. Would you be able to take a stab at that?

@villebro
Copy link
Member

villebro commented Jan 3, 2024

@rekilina I'll go ahead and merge this one and follow up with a test PR, as the test suite is arguably pretty messy in its current state. But if you want to add the test, let me know by tagging me here so I can avoid opening a new PR for it.

@villebro villebro merged commit a0f0f69 into apache:master Jan 3, 2024
31 checks passed
@michael-s-molina michael-s-molina added v3.0 Label added by the release manager to track PRs to be included in the 3.0 branch v3.1 Label added by the release manager to track PRs to be included in the 3.1 branch labels Jan 3, 2024
sivasathyaseeelan pushed a commit to sivasathyaseeelan/superset that referenced this pull request Jan 3, 2024
michael-s-molina pushed a commit that referenced this pull request Jan 4, 2024
michael-s-molina pushed a commit that referenced this pull request Jan 9, 2024
josedev-union pushed a commit to Ortege-xyz/studio that referenced this pull request Jan 22, 2024
@mistercrunch mistercrunch added 🍒 3.0.3 🍒 3.0.4 🍒 3.1.0 🍒 3.1.1 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels labels Mar 8, 2024
sfirke pushed a commit to sfirke/superset that referenced this pull request Mar 22, 2024
vinothkumar66 pushed a commit to vinothkumar66/superset that referenced this pull request Nov 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/XS v3.0 Label added by the release manager to track PRs to be included in the 3.0 branch v3.1 Label added by the release manager to track PRs to be included in the 3.1 branch 🍒 3.0.3 🍒 3.0.4 🍒 3.1.0 🍒 3.1.1 🍒 3.1.2 🍒 3.1.3 🚢 4.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants