Skip to content
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

Merged
merged 5 commits into from
Jul 23, 2024

Conversation

sebastian-aranda
Copy link
Contributor

@sebastian-aranda sebastian-aranda commented Jul 19, 2024

This PR adds some memoization to properties used by the MultiSelect component on the NightReport component. As the NightReport has an interval that re-renders it for triggering alerts in case some time have passed, the MultiSelect 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 the MultiSelect doesn't get re-rendered on parent renders.

Copy link
Contributor

@couger01 couger01 left a 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),
Copy link
Contributor

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.

Copy link
Contributor Author

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 👍.

@sebastian-aranda sebastian-aranda merged commit 266ea40 into develop Jul 23, 2024
2 checks passed
@sebastian-aranda sebastian-aranda deleted the tickets/DM-45352 branch July 23, 2024 21:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants