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 issue with popovers not working in embedded app modals when put inside of a details component #12534

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

vividviolet
Copy link
Member

Enable popover display state to be updated based on the parent's resize event.

Screen.Recording.2024-08-09.at.10.24.53.PM.mov

WHY are these changes introduced?

Fixes #12445 (comment)

WHAT is this pull request doing?

Attach the resize observer to the parent element of the activator when available instead of the activator itself.

How to 🎩

🖥 Local development instructions
🗒 General tophatting guidelines
📄 Changelog guidelines

🎩 checklist

…nside of a details component

Enable popover display state to be updated based on the parent's resize event.
@vividviolet
Copy link
Member Author

/snapit

Copy link
Contributor

🫰✨ Thanks @vividviolet! Your snapshot has been published to npm.

Test the snapshot by updating your package.json with the newly published version:

"@shopify/polaris": "0.0.0-snapshot-20240810023129"

@bakura10
Copy link

Thanks for working on that :). However it does not seem to work if the popover is nested in a div inside the details.

*/

observer.observe(
activatorContainer.current.parentElement || activatorContainer.current,

Choose a reason for hiding this comment

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

I think a more robust approach would be to recursively get the parent element until you find one where offsetParent !== null:

let elementToObserve = activatorContainer.current;

while (elementToObserve.offsetParent !== null) {
  elementToObserve = elementToObserve.parentElement;
}

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