-
Notifications
You must be signed in to change notification settings - Fork 6
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 observers dropdown on the NightReport component #655
Conversation
fad3c82
to
2a148f2
Compare
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 but one suggested variable change.
function ObserversField({ isEditDisabled, observersFieldRef, userOptions, selectedUsers, setSelectedUsers }) { | ||
function ObserversField({ isEditDisabled, userOptions, selectedUsers, setSelectedUsers }) { | ||
const memoizedSelectedValueDecorator = useCallback( | ||
(v) => (v.length > MULTI_SELECT_OPTION_LENGHT ? `...${v.slice(-MULTI_SELECT_OPTION_LENGHT)}` : v), |
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.
Length has a typo here. Might be good to fix for better maintenance.
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.
thanks for catching that! I'll make the change 👍.
… prevent unexpected renders on the users dropdown
…used in the `NightReport` component
2a148f2
to
6ab3668
Compare
This PR adds some memoization to properties used by the
MultiSelect
component on theNightReport
component. As theNightReport
has an interval that re-renders it for triggering alerts in case some time have passed, theMultiSelect
component was being also re-rendered leading to unexpected behaviors as trying to select users and the dropdown being closed suddenly. By memoizing props we ensure theMultiSelect
doesn't get re-rendered on parent renders.