-
Notifications
You must be signed in to change notification settings - Fork 13.9k
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: allow to select <NULL> in a native filter single mode #19076
fix: allow to select <NULL> in a native filter single mode #19076
Conversation
Codecov Report
@@ Coverage Diff @@
## master #19076 +/- ##
==========================================
- Coverage 66.54% 66.54% -0.01%
==========================================
Files 1646 1646
Lines 63630 63630
Branches 6475 6476 +1
==========================================
- Hits 42343 42342 -1
Misses 19607 19607
- Partials 1680 1681 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
@michael-s-molina @geido could one of you approve this as codeowners? |
@rusackas Before approving this PR we need to discuss how are we going to deal with
This change, for instance, shouldn't be valid because
I already talked to @geido about this we will schedule a meeting to discuss the best approach. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's ok to allow option.value
to be of arbitrary type, as long as there is a option.label
string for display and search.
@@ -61,7 +61,7 @@ export function findValue<OptionType extends OptionTypeBase>( | |||
} | |||
|
|||
export function getValue(option: string | number | { value: string | number }) { | |||
return typeof option === 'object' ? option.value : option; | |||
return option && typeof option === 'object' ? option.value : option; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we are allowing option
to be null
then we need to update the signature of getValue
as well (add | null
).
@michael-s-molina @ktmud yeah, agreed. |
@diegomedina248 We discussed |
@@ -61,7 +61,7 @@ export function findValue<OptionType extends OptionTypeBase>( | |||
} | |||
|
|||
export function getValue(option: string | number | { value: string | number }) { | |||
return typeof option === 'object' ? option.value : option; | |||
return option && typeof option === 'object' ? option.value : option; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return option && typeof option === 'object' ? option.value : option; | |
return typeof option === 'object' ? option.value : option; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typeof option === 'object'
returns true when the value is null
, that's why the change.
Repl.it: https://replit.com/@DiegoMedina6/BaggyGratefulAdware#index.js
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The option shouldn't be null
because we need a label to describe the null
value. The value of an object option is null
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The getValue
is called with the selectValue
in which we store the value itself, not the option (for multi select, an array of the values)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@diegomedina248 Please disregard my previous message. To support Ant Design's different behavior depending on whether labelInValue
is active, we need to also account for an option being null
. You can keep your last commit where getValue(option: string | number | { value: string | number | null } | null)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks for the fix @diegomedina248!
We currently have a broken frontend test related to timezone issues. People are already looking into it. As soon as they fix it you will need to rebase your PR.
8546d83
to
7a324df
Compare
Co-authored-by: Michael S. Molina <70410625+michael-s-molina@users.noreply.github.com>
7a324df
to
d796c65
Compare
🏷️ preset:2022.11 |
) * fix: allow to select <NULL> in a native filter single mode * fix lint issue * Update superset-frontend/src/components/Select/utils.ts Co-authored-by: Michael S. Molina <70410625+michael-s-molina@users.noreply.github.com> * fix Co-authored-by: Michael S. Molina <70410625+michael-s-molina@users.noreply.github.com> (cherry picked from commit 19fcd03)
* fix: allow to select <NULL> in a native filter single mode * fix lint issue * Update superset-frontend/src/components/Select/utils.ts Co-authored-by: Michael S. Molina <70410625+michael-s-molina@users.noreply.github.com> * fix Co-authored-by: Michael S. Molina <70410625+michael-s-molina@users.noreply.github.com> (cherry picked from commit 19fcd03)
SUMMARY
The native filter used in the Dashboard filters values in single mode, which is a valid state.
The filter needs to be made only on
undefined
specifically.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Fix demo:
Screen.Recording.2022-03-09.at.11.07.53.mov
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION