-
-
Notifications
You must be signed in to change notification settings - Fork 229
Single frame positioning glitch in concurrent mode #349
Comments
Thanks for the report! I think we could set a |
Thanks. I was thinking along those lines, though there is the other detail of the issue (which I'm having trouble creating an effective demo for), where the popper appears at the old position before updating to the new one on some occasions. It basically looks like the popper tries to show before it's ready when the reference is (re-)positioned rather than just on the first update. I'll keep trying to create a demo for this, or failing that a screencap of it on my project. |
@jamiewinder @FezVrasta if you make react do a bit more work it's easy to reproduce. See https://codesandbox.io/s/react-popper-glitch-forked-vnt5z I've worked around this in my code via: <div
style={{
...styles.popper,
visibility: !styles.popper.transform ? 'hidden': 'visible',
}}
>
...
</div> |
This same issue has been reported in semantic-ui-react, see here, which uses react-popper. Adding a link here for reference. I suggested a possible fix in usePopper.js, but not sure if it is the right fix. |
@therealgilles This also happens in https://floating-ui.com/docs/react-dom which doesn't set From debugging, it appears to be due to the positioning state update occurring asynchronously (in a microtask). Popper does this for the first update, while Floating UI's whole API is async to support async platform measurement methods like in React Native. The Screen.Recording.2022-04-11.at.3.17.18.pm.movI think this is because the |
It looks like we need to use the new |
Apparently |
I think this is specific to React's experimental concurrent mode, though it occurs with both
createRoot
andcreateBlockingRoot
.When used in either, the popper can briefly appear in the top-left of the viewport before shifting into the correct position. If the popper instance had calculated a position already, then it'll briefly appear in the old position before moving to the new one (though that isn't demonstrated in this demo to keep it simple).
This only occurs for a frame, and is often easy to miss. It appears to affect both the hook and the old render prop. If you change React back to the non-concurrent mode (e.g.
ReactDOM.render
) then the problem appears to go away.I've made a demo to demonstrate this.
Reproduction demo
https://codesandbox.io/s/react-popper-glitch-lcvdm?file=/src/index.js
Steps to reproduce the problem
The text was updated successfully, but these errors were encountered: