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(dropdown): memoize floating ui ref to prevent max call depth #17002

Merged
merged 2 commits into from
Jul 19, 2024

Conversation

EAlexRojas
Copy link
Contributor

Closes #17001

Applies similar approach as for the Combobox component (in #16866) to memoize the value of getMenuProps to avoid an infinite loop.

Changelog

Changed

  • Wrap getMenuProps in useMemo
  • Conditionally apply refs

Testing / Reviewing

  • Go to default dropdown story. Verify there is no regression for default behaviour.
  • Ensure autoAlign works as expected on dropdown by resizing the browser window, playing with scroll, and opening/closing the listbox
  • The original issue only appeared when running cypress tests, only way to validate this fixes the bug in that case would be to add a cypress test for the Dropdown component.

Note: The fix was validated in an existing app by applying a patch.

@EAlexRojas EAlexRojas requested a review from a team as a code owner July 19, 2024 12:34
Copy link
Contributor

github-actions bot commented Jul 19, 2024

All contributors have signed the DCO.
Posted by the DCO Assistant Lite bot.

Copy link

netlify bot commented Jul 19, 2024

Deploy Preview for v11-carbon-react ready!

Name Link
🔨 Latest commit 63ea762
🔍 Latest deploy log https://app.netlify.com/sites/v11-carbon-react/deploys/669aa3f63e807c000858a527
😎 Deploy Preview https://deploy-preview-17002--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 19, 2024

Deploy Preview for carbon-elements ready!

Name Link
🔨 Latest commit 63ea762
🔍 Latest deploy log https://app.netlify.com/sites/carbon-elements/deploys/669aa3f6c064780008a0a073
😎 Deploy Preview https://deploy-preview-17002--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.

@EAlexRojas
Copy link
Contributor Author

I have read the DCO document and I hereby sign the DCO.

Copy link
Member

@tay1orjones tay1orjones left a comment

Choose a reason for hiding this comment

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

Thanks for catching this, submitting the fix, and testing it! Since it's so close to that other PR and you've said it fixes your test case, I think this looks good to merge

Copy link
Contributor

@guidari guidari 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 19, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jul 19, 2024
@tay1orjones tay1orjones added this pull request to the merge queue Jul 19, 2024
Merged via the queue into carbon-design-system:main with commit 1be65d7 Jul 19, 2024
22 checks passed
2nikhiltom pushed a commit to 2nikhiltom/carbon that referenced this pull request Jul 22, 2024
@2nikhiltom 2nikhiltom mentioned this pull request Jul 22, 2024
2nikhiltom pushed a commit to 2nikhiltom/carbon that referenced this pull request Jul 22, 2024
2nikhiltom pushed a commit to 2nikhiltom/carbon that referenced this pull request Jul 22, 2024
2nikhiltom pushed a commit to 2nikhiltom/carbon that referenced this pull request Jul 22, 2024
riddhybansal pushed a commit to riddhybansal/carbon that referenced this pull request Jul 22, 2024
@2nikhiltom 2nikhiltom mentioned this pull request Jul 22, 2024
tay1orjones added a commit to tay1orjones/carbon that referenced this pull request Jul 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Dropdown crashes with "Error: Maximum update depth exceeded..." coming from floating-ui
3 participants