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: memoize getMenuProps for Multiselect and Filterable Multiselect #17022

Merged

Conversation

riddhybansal
Copy link
Contributor

Closes #16867
Closes #17021
Closes #17020

This PR does these primary things to Multiselect and Filterable Multiselect

  1. Memoize the value of getMenuProps to avoid an infinite loop
  2. Only apply floating ui refs when autoAlign={true}

The first fixes the problem for max depth call that results in infinite loop, the second is an indirect improvement. If the refs had initially been guarded, this bug would've been isolated to users using autoAlign. Because the refs were not guarded, the bug was present for everyone regardless of if autoAlign was being used.

This PR also verifies if the refs of components - popover, tooltip, dropdown, are guarded with autoalign prop.

Changelog

Changed

  • Wrap getMenuProps in useMemo to multiselect and filterable multiselect
  • Conditionally apply or verify refs in multiselect , filterable multiselect , popover, tooltip, dropdown

Testing / Reviewing

  • Go to the default multiselect story. Type super fast - like just totally spam the keyboard. The component should not error
  • Do the same on the with experimental autoalign multiselect story
  • Ensure autoAlign works as expected on multiselect by resizing the browser window, playing with scroll, and opening/closing the listbox
  • Do the same for filterable multiselect.

@riddhybansal riddhybansal requested a review from a team as a code owner July 23, 2024 08:41
Copy link

netlify bot commented Jul 23, 2024

Deploy Preview for v11-carbon-react ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit b082f48
🔍 Latest deploy log https://app.netlify.com/sites/v11-carbon-react/deploys/669f6cb9e00b2f0009e2272d
😎 Deploy Preview https://deploy-preview-17022--v11-carbon-react.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Jul 23, 2024

Deploy Preview for carbon-elements ready!

Name Link
🔨 Latest commit b082f48
🔍 Latest deploy log https://app.netlify.com/sites/carbon-elements/deploys/669f6cb9e2a8ad00081dae74
😎 Deploy Preview https://deploy-preview-17022--carbon-elements.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Contributor

@2nikhiltom 2nikhiltom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me 💯

Copy link
Contributor

@preetibansalui preetibansalui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@guidari guidari added this pull request to the merge queue Jul 23, 2024
Merged via the queue into carbon-design-system:main with commit 8fe1ee3 Jul 23, 2024
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants