You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "michael-s-molina (via GitHub)" <gi...@apache.org> on 2024/03/27 14:47:20 UTC
[PR] fix: Select onChange is fired when the same item is selected in single mode [superset]
michael-s-molina opened a new pull request, #27706:
URL: https://github.com/apache/superset/pull/27706
### SUMMARY
Prevents Select's `onChange` from being fired when the same item is selected in single mode.
Fixes https://github.com/apache/superset/issues/27668.
### TESTING INSTRUCTIONS
CI.
### ADDITIONAL INFORMATION
- [ ] Has associated issue:
- [ ] Required feature flags:
- [ ] Changes UI
- [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
- [ ] 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
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix: Select onChange is fired when the same item is selected in single mode [superset]
Posted by "michael-s-molina (via GitHub)" <gi...@apache.org>.
michael-s-molina merged PR #27706:
URL: https://github.com/apache/superset/pull/27706
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix: Select onChange is fired when the same item is selected in single mode [superset]
Posted by "kgabryje (via GitHub)" <gi...@apache.org>.
kgabryje commented on code in PR #27706:
URL: https://github.com/apache/superset/pull/27706#discussion_r1542927641
##########
superset-frontend/src/components/Select/utils.tsx:
##########
@@ -49,22 +49,25 @@ export function getValue(
return isLabeledValue(option) ? option.value : option;
}
+export function equalValues(a: V | LabeledValue, b: V | LabeledValue) {
+ const actualA = isObject(a) && 'value' in a ? a.value : a;
+ const actualB = isObject(b) && 'value' in b ? b.value : b;
+ // When comparing the values we use the equality
+ // operator to automatically convert different types
+ // eslint-disable-next-line eqeqeq
+ return actualA == actualB;
+}
+
export function getOption(
value: V,
options?: V | LabeledValue | (V | LabeledValue)[],
checkLabel = false,
): V | LabeledValue {
const optionsArray = ensureIsArray(options);
- // When comparing the values we use the equality
- // operator to automatically convert different types
return optionsArray.find(
x =>
- // eslint-disable-next-line eqeqeq
- x == value ||
- (isObject(x) &&
- // eslint-disable-next-line eqeqeq
- (('value' in x && x.value == value) ||
- (checkLabel && 'label' in x && x.label === value))),
+ equalValues(x, value) ||
+ (checkLabel && isObject(x) && 'label' in x && x.label === value),
Review Comment:
Do you think it makes sense to extend `equalValues` to accept "key" argument, so you could call `equalValues(x, checkLabel, "label")` here?
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix: Select onChange is fired when the same item is selected in single mode [superset]
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #27706:
URL: https://github.com/apache/superset/pull/27706#issuecomment-2023026603
## [Codecov](https://app.codecov.io/gh/apache/superset/pull/27706?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 69.77%. Comparing base [(`349e496`)](https://app.codecov.io/gh/apache/superset/commit/349e496da519f3462aa5cff2d1bd76490b04fe5d?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) to head [(`7e3a4c6`)](https://app.codecov.io/gh/apache/superset/pull/27706?dropdown=coverage&src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## master #27706 +/- ##
==========================================
- Coverage 69.77% 69.77% -0.01%
==========================================
Files 1911 1911
Lines 75056 75065 +9
Branches 8362 8366 +4
==========================================
+ Hits 52374 52375 +1
- Misses 20630 20640 +10
+ Partials 2052 2050 -2
```
| [Flag](https://app.codecov.io/gh/apache/superset/pull/27706/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [javascript](https://app.codecov.io/gh/apache/superset/pull/27706/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `57.48% <100.00%> (-0.02%)` | :arrow_down: |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
</details>
[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/superset/pull/27706?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix: Select onChange is fired when the same item is selected in single mode [superset]
Posted by "michael-s-molina (via GitHub)" <gi...@apache.org>.
michael-s-molina commented on code in PR #27706:
URL: https://github.com/apache/superset/pull/27706#discussion_r1542967221
##########
superset-frontend/src/components/Select/utils.tsx:
##########
@@ -49,22 +49,25 @@ export function getValue(
return isLabeledValue(option) ? option.value : option;
}
+export function equalValues(a: V | LabeledValue, b: V | LabeledValue) {
+ const actualA = isObject(a) && 'value' in a ? a.value : a;
+ const actualB = isObject(b) && 'value' in b ? b.value : b;
+ // When comparing the values we use the equality
+ // operator to automatically convert different types
+ // eslint-disable-next-line eqeqeq
+ return actualA == actualB;
+}
+
export function getOption(
value: V,
options?: V | LabeledValue | (V | LabeledValue)[],
checkLabel = false,
): V | LabeledValue {
const optionsArray = ensureIsArray(options);
- // When comparing the values we use the equality
- // operator to automatically convert different types
return optionsArray.find(
x =>
- // eslint-disable-next-line eqeqeq
- x == value ||
- (isObject(x) &&
- // eslint-disable-next-line eqeqeq
- (('value' in x && x.value == value) ||
- (checkLabel && 'label' in x && x.label === value))),
+ equalValues(x, value) ||
+ (checkLabel && isObject(x) && 'label' in x && x.label === value),
Review Comment:
Good call. Done.
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org