-
Notifications
You must be signed in to change notification settings - Fork 160
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 save quick edit modals #4742
Fix save quick edit modals #4742
Conversation
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.
Changes make sense to me! I'll leave the final approval to @AllanOXDi. Thanks @AlexVelezLl for noticing this and the change.
Thank you @akolson. I have fixed and added some unit tests to spot regressions like these 🤗 |
0723776
to
ea91300
Compare
@@ -174,7 +176,7 @@ | |||
Object.assign(fieldValue, currentNode[this.field] || {}); | |||
} | |||
Object.entries(this.selectedValues) | |||
.filter(([value]) => value.length === this.nodeIds.length) | |||
.filter(entry => entry[1].length === this.nodeIds.length) |
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.
Great catch! On correcting the filter. Changing the check to entry[1].length === this.nodeIds.length
ensures we're filtering the selected values properly, as the second element of the entries represents the value, not the first.
@@ -107,7 +107,9 @@ | |||
}, | |||
canSave() { | |||
if (this.hasMixedCategories) { | |||
return Object.values(this.selectedValues).some(value => value.length > 0); | |||
return Object.values(this.selectedValues).some( | |||
value => value.length === this.nodes.length |
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 updated condition now ensures saving is only allowed when the selected values cover all nodes , which makes validation more robust. What would happen if partial selections are ever needed in other scenarios? maybe we might want to consider making this condition more flexible?
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.
Hey! The thing is that "partial selections" just only serve to determine if we have mixedCategories, but the user doesnt see nor interact with any of these partial selections. For them they dont exists, so thats why we cant depend on them, and rather depend on what they are seeing which is selected options, and we have selected options when we have that value.length === this.nodes.length
.
If we keep the condition of value.length > 0
then we will be taking these mixed options as valid values. So if I have for example 2 nodes:
Node 1:
- Category A selected
Node 2:
- Category B selected
Then when we open the modal, we will see the mixed options comment, but we wont see any of the options selected, because we dont have any option selected across all nodes, and we wont see any indeterminate state as they dont exist anymore, the only the user will se will be all checkboxes unchecked. But the user will still see the save button enabled, because canSave = true
because all category A and B have value.length > 0
, and this is an error, as we are not meeting the 4th acceptance criteria mentioned in #4651:
the "save" button only be active if one or more boxes is checked, but no validation is required (and no error message)
So, no, we cant have a more flexible condition as this condition does not met the requirements.
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.
Thank you for explaining the reasoning behind the stricter condition.
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.
With all comments addressed, approving this and merging. Thanks @AlexVelezLl @AllanOXDi
Summary
Description of the change(s) you made
Fix save edit boolean map modals. This PR fixes two things:
this.selectedValues
that have all nodes inside, but we havewhich is an error as the value is the second element of the entries, not the first.
.some(value => value.length === this.nodes.length)
, but we have.some(value => value.length > 0)
and this is an error as this condition is true for values that arent selected across all nodes.Contributor's Checklist
PR process:
CHANGELOG
label been added to this PR. Note: items with this label will be added to the CHANGELOG at a later timedocs
label has been added if this introduces a change that needs to be updated in the user docs?requirements.txt
files also included in this PRStudio-specifc:
notranslate
class been added to elements that shouldn't be translated by Google Chrome's automatic translation feature (e.g. icons, user-generated text)pages
,components
, andlayouts
directories as described in the docsTesting:
Reviewer's Checklist
This section is for reviewers to fill out.
yarn
andpip
)