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 incorrect positioning of clickable area for navigation links on Safari #1403
Conversation
The current (v0.7.0) code is
I fear it would significantly undermine the benefit of the automatic scrolling. I much prefer to see at least a bit of the context of the selected link (e.g., so as to be able to select a close sibling).
I think the See also the detailed motivation for the
The MDN browser compatibility overview indicates that the The Can I use summary doesn't detail the degree of browser support for the Footnotes
|
Great point! I've changed it in 3d6e39f (so it's live on the deploy preview); what are your thoughts? I agree that after some local testing, this behaviour is better (and closer in intention to the original code here).
I'm not too concerned about this:
targetLink.scrollIntoView({ block: "center", peter: "mosses" }); doesn't throw any errors in any browser, since the |
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.
I've tested the preview in Safari, Firefox, and Chrome, and the centred navigation scroll works as expected. The incorrect positioning in Safari has disappeared.
The JS update LGTM, and I don't get any JS errors in Safari or Chrome.
Firefox (121.0) reports the following error, but it appears also when browsing v0.7.0 so it isn't related to this PR.
Error in parsing value for ‘-webkit-text-size-adjust’. Declaration dropped.
[normalize.scss:13:2](https://deploy-preview-1403--just-the-docs.netlify.app/_sass/vendor/normalize.scss/normalize.scss)
Thanks for the review!
Oh interesting, I hadn't noticed this before. Doing a quick look at
However, Chromium (on desktop & android) seems to have supported it for a while, as does mobile safari; the latter does it with the vendor prefix (I found this article by Kilian Valhof to be a good starting place; it seems like most major "resets" include this) What are your thoughts? If you think it's worthwhile, I'm happy to poke at it for a bit. |
Unless our users complain about it, let's ignore this discrepancy between the current versions of Firefox and |
Closes #1392.
Unfortunately, this PR has not actually diagnosed the root problem with the
scrollBy
calculation/method and Safari. However, by using thescrollIntoView
function (which essentially does what the calculation was meant to do), this problem is "magically" solved! As a side effect, I think this makes the code easier to maintain (I myself was thinking: why is there a magic3
multiplier?).I will point out that this does change how much is scrolled; following the spec for the method, the sidebar is now scrolled so that the active navigation link is top-aligned with the scroll container (which in this case, is the navigation sidebar's "cutoff"). I personally am fine with this change, but happy to fiddle around (e.g. we could vertically align to thecenter
viascrollIntoViewOptions
, though I'm not sure if this causes compatability problems).I will point out that this does change how much is scrolled; we are now using the
center
option toscrollBy
, which centers the target link. As Peter has commented in the PR thread, this seems to be the best compromise for maintaining the spirit of the previous calculation.testing
@pdmosses did a great job writing a reproducible bug report in #1392. To test this,
main
. observe that the bug appears on Safari on macOS, but not Firefox and Chromecompatability
On Can I use,
scrollIntoView
has 98.15% adoption (the only "major" holdout being Opera Mini); and, the partial support from IE is about an option that we don't use. So, I'm pretty confident that we should be able to roll out this change without our users being locked out by a new-ish method.