-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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: make sure page is not scrolled all way up on load #1009
Conversation
ℹ️ View Unchanged
|
All of the failing tests? 🤣 Odd that this has now come up twice in one day 🤔 did some browser behavior change recently? floating-ui/react-popper#336 It seems like we'd need to use the |
src/modifiers/applyStyles.js
Outdated
@@ -37,7 +37,7 @@ function applyStyles({ state }: ModifierArguments<{||}>) { | |||
function effect({ state }: ModifierArguments<{||}>) { | |||
const initialStyles = { | |||
popper: { | |||
position: 'absolute', | |||
position: 'fixed', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
position: 'fixed', | |
position: state.options.strategy, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if you want the absolute strategy, but don't want the scroll to happen? Not sure this would fix our issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed it won't. I think you need to prevent focus before Popper has positioned it (onFirstUpdate
and after)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would visibility: hidden
help?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems it would help, we'd need to set the popper to visibility: hidden
and set it back to visible
after we positioned it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll need to unset it on onFirstUpdate
as well, where you could do the focusing? 🤷♂
https://codepen.io/atomiks/pen/KKpMOyV
visibility: hidden
won't scroll to the input. What works best is calling .focus()
in onFirstUpdate
if you want "autofocus / initialfocus" behavior which will scroll the input if needed, in its correct location.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test this in the "debug view" (iframes block the autofocus
behavior)
https://codepen.io/FezVrasta/pen/wvaWVyw
there's not need for the .focus()
call
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't call a focus in our usage, it's just the user is scrolled down the page and then this pushes them to the top. We do a call to scrollIntoView() for the target. Even removing that scrolls the user to the top of the page.
3bf49e9
to
090f3b0
Compare
I'm not convinced we should bother fixing this? Adding the The user should always call |
@atomiks are you saying the intended popper behavior is to scroll to the top of the page every time before then scrolling down to the popper? That seems less than ideal. |
@rwwagner90 I think @atomiks' point is that Popper aims to be a low level positioning library, we tend to defer any non-positioning related problem to the libraries that provide the actual "tooltip features" the mainstream users need. In this optic, adding a specific fix for this issue, at the cost of limiting some users that need to have more control over the rendering phase of the elements, may be out of scope for the project. Probably we could leverage on a 3rd party modifier for this kind of use cases though. |
@FezVrasta I don't have a ton of context, but I would expect showing a popper always scrolling the page to the top to be a blocker level bug. I think as a user, I would expect it to work and ship with that modifier you are describing out of the box. I think the more in depth tooltip libraries should be able to override that as needed though. |
@rwwagner90 I see your point, given the complexity of the library it's always a matter of trade-offs, if we add too much functionality, users will complain about the library weight, if we keep it lean, users will complain about edge-cases not handled out of the box. As a rule of thumb, anything reported more than a couple of times should be considered to go into the library, for all the other one-off requests, we advise to write ad-hoc modifiers. To unblock you while we work on a solution (or a "wontfix"), I would suggest to set To @atomiks:
The problem here is not about May you help me understand why this PR is breaking Tippy so that we can think about a solution? |
This only happens when you focus though... when I search for As I recall, |
@atomiks you were right and it ended up being an issue with |
@FezVrasta I think we can close this |
For context see further: floating-ui/floating-ui#1009
This should fix the issue reported here shipshapecode/shepherd#744 (comment)
@atomiks can you see any downside of this approach?