Skip to content
This repository has been archived by the owner on Dec 5, 2024. It is now read-only.

fix: change initial position style based on positionFixed prop #336

Merged
merged 2 commits into from
Feb 25, 2020

Conversation

zkuzmic
Copy link
Contributor

@zkuzmic zkuzmic commented Feb 18, 2020

I have a scenario where I am autofocusing an element appearing inside of a popper, and that is causing the page to scroll to the top when initially opened. A similar issue can be found here:

mui/material-ui#16740

Their solution was to add position: fixed to the initial styles on the popper, but this library doesn't offer a way to do that. This PR makes it so that initial position style will either be absolute or fixed based on the positionFixed prop provided to the Popper component.

@zkuzmic zkuzmic requested a review from FezVrasta February 18, 2020 20:50
@zkuzmic
Copy link
Contributor Author

zkuzmic commented Feb 19, 2020

Quoting a comment from @atomiks on floating-ui/floating-ui#1009

The user should always call .focus() after the popper was positioned, never before. They can also set visibility themselves too.

That makes total sense to me, although there doesn't appear to be a way to do that with the current react-popper api. Or am I missing something?

@zkuzmic
Copy link
Contributor Author

zkuzmic commented Feb 24, 2020

@FezVrasta any suggestions for this PR or anything I can do to help get this merged?

@FezVrasta FezVrasta changed the title changed initial position style based on positionFixed prop fix: change initial position style based on positionFixed prop Feb 25, 2020
@FezVrasta FezVrasta merged commit 4ddde9d into floating-ui:master Feb 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants