-
Notifications
You must be signed in to change notification settings - Fork 3k
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 remove button remains enabled when removing a user in other device #18934
Conversation
@danieldoglas @s77rt One of you needs to copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
@@ -96,6 +96,15 @@ class WorkspaceMembersPage extends React.Component { | |||
this.validate(); | |||
} | |||
|
|||
if (!_.isEqual(prevProps.policyMemberList, this.props.policyMemberList)) { |
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 don't think we need deep comparison here (_.isEqual
). Just a shallow comparison will do it.
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.
@s77rt I just updated.
this.setState((prevState) => { | ||
const selectedEmployees = _.filter(prevState.selectedEmployees, (selectedEmployee) => _.has(this.props.policyMemberList, selectedEmployee)); | ||
return { | ||
selectedEmployees, | ||
}; | ||
}); |
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.
Didn't you propose to use intersection? Is there something wrong with that?
this.setState((prevState) => ({
selectedEmployees: _.intersection(prevState.selectedEmployees, this.props.policyMemberList),
}));
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.
selectedEmployees is a string array, but policyMemberList is an object that has key is an email of user
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.
Right, this should do it then
this.setState((prevState) => ({
selectedEmployees: _.intersection(prevState.selectedEmployees, _.keys(this.props.policyMemberList)),
}));
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 main purpose of my solution is the way to fix this issue and this code above is for illustration purposes only.
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.
Can you apply the suggested fix
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.
@s77rt Sorry, I missed your suggestion above. I will update right now.
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.
@s77rt I just updated, please help to check again.
Reviewer Checklist
Screenshots/VideosWebweb.mp4Mobile Web - Chromemweb-chrome.mp4Mobile Web - Safarimweb-safari.mp4Desktopdesktop.mp4iOSios.mp4Androidandroid.mp4 |
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! 🚀
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to staging by https://github.com/danieldoglas in version: 1.3.15-0 🚀
|
🚀 Deployed to production by https://github.com/yuwenmemon in version: 1.3.15-12 🚀
|
@@ -96,6 +96,12 @@ class WorkspaceMembersPage extends React.Component { | |||
this.validate(); | |||
} | |||
|
|||
if (prevProps.policyMemberList !== this.props.policyMemberList) { |
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'm pretty sure policyMemberList
is an array, and !==
can't be used to compare array length / values - they're just pointers in JS. So this is only checking that the pointers are the same, not that the values in the arrays are the same - is that what y'all are trying to do?
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.
Yes, that's exactly what we are trying to do. I have requested this change here #18934 (comment).
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.
Huh, i haven't seen that idea on purpose before (checking if pointers stay the same) - seems fishy but you're sure this works? 😅
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.
😅 Yeah I'm sure. The idea is to do some logic only if the pointer change. If the pointer change then it's likely the values are changed too (if the pointer change but we have same values than this is a bad design somewhere else, yet it won't cause any bug if this ever happened). Also there is no case where the values change but keep using the same pointer (onyx do not mutate objects). This is just an optimisation (comparing addresses should be the fastest).
Just curious though, how did you end up here 😁?
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.
Innnnnnnnnteresting, that all sounds legit! 👍 Thanks for explaining :D
Hahaha I ended up here just because i saw some arrays being compared and had to ask why 😅
if (prevProps.policyMemberList !== this.props.policyMemberList) { | ||
this.setState((prevState) => ({ | ||
selectedEmployees: _.intersection(prevState.selectedEmployees, _.keys(this.props.policyMemberList)), | ||
})); |
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.
✋ Coming from #28551
This is an excellent start to aligning the policyMembers
. The attached issue is another case in which we want to keep the selected optimistic members' accountID
aligned with the new accountID
from the API response, so the selection remains.
Details
Remove button remains enabled when removing a user in other device.
Fixed Issues
$ #17166
PROPOSAL: #17166 (comment)
Tests
Offline tests
Same above
QA Steps
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Web
Screencast.from.15-05-2023.14.50.56.webm
Mobile Web - Chrome
Record_2023-05-15-14-51-23.mp4
Mobile Web - Safari
Screen-Recording-2023-05-15-at-17.00.28.mp4
Desktop
Screen-Recording-2023-05-15-at-17.01.56.mp4
iOS
Screen-Recording-2023-05-15-at-17.15.36.mp4
Android
17166.mp4