htmx icon indicating copy to clipboard operation
htmx copied to clipboard

hx-boost strange behaviour

Open markski1 opened this issue 2 years ago • 5 comments

There is a strange behaviour when using hx-boost. As you can see in this video, clicking on two sites causes a slight downwards scroll. The video is on Firefox, but on Edge it happens too, albeit the animation is quicker, it'll scroll to the point of the title tag being right at the top of the page.

The live site, on https://sam.markski.ar , uses individual hx-get tags on every link, and works without this behaviour.

https://github.com/bigskysoftware/htmx/assets/22557859/acaae72d-d2a8-4304-b7af-3b01926449e9

These are the only changes made between the live site and the one in the video:

imagen

Edit PS: Because I just realized it may be confusing, it is worth noting that the sidebar has a position of "fixed" and that's why it doesn't move. In reality the whole browser is scrolling.

markski1 avatar Aug 29 '23 06:08 markski1

I was passing by and noticed your issue.I've tested it on my browser and didn't encounter any issues.

MeSilicon7 avatar Aug 29 '23 08:08 MeSilicon7

Note again that the live site works WITHOUT this behaviour. The behaviour only shows up when the changes shown in that diff are made.

markski1 avatar Aug 29 '23 19:08 markski1

I'm experiencing this as well using version 1.9.4.

jvcop avatar Sep 06 '23 08:09 jvcop

I've noticed this behavior too. In my case it was caused by top margin on the first element in the document flow. It seems that on navigation, HTMX boost scrolls to the top of the page content, and if that content is offset by margin, it will cause this slight scroll. Try using padding instead.

onvlt avatar Feb 01 '24 16:02 onvlt