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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extra span in portal triggering flex issues. #902

Closed
kentcdodds opened this issue Jan 25, 2022 · 4 comments
Closed

Extra span in portal triggering flex issues. #902

kentcdodds opened this issue Jan 25, 2022 · 4 comments

Comments

@kentcdodds
Copy link
Contributor

馃悰 Bug report

Current Behavior

I've got a menu button inside a flex container. This extra span is causing me grief (layout shift):

menu-button.mov

Here's what it looks like before hydration:

image

Here it is after hydration:

image

Expected behavior

Wrapping the button in a flex container makes the sibling span trigger a content shift.

Reproducible example

https://stackblitz.com/edit/node-qppzt9?file=app%2Froot.tsx

Suggested solution(s)

Maybe don't render anything on the server render?

A workaround (that I'm implementing) is to wrap the <Menu> inside a <div> so the sibling span doesn't end up messing up the flex flow. But this was surprising.

Additional context

This seems to only be a problem when server rendering.

Your environment

Software Name(s) Version
Reach Package @reach/portal and @reach/menu latest
React dom 17
Browser any any
Assistive tech
Node
npm/yarn
Operating System
@artursvonda
Copy link

Similar issue but causes warnings when rendered in context where span is not suited (like tbody).

@chaance
Copy link
Member

chaance commented Apr 20, 2022

I'm thinking we should add a prop to Portal that skips mounting before hydration. That's probably the right default for menu button and listbox since neither of these dropdowns need to be rendered on the server anyway.

@chaance
Copy link
Member

chaance commented Apr 20, 2022

Fixed in v0.17.0

@chaance chaance closed this as completed Apr 20, 2022
@kentcdodds
Copy link
Contributor Author

Thanks!

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

No branches or pull requests

3 participants