bigskysoftware / bigskysoftware/htmx
`show:` or `scroll:` with only `top` should use `window.scrollTo(0,0)` for consistent behavior
- Dominant language
- JavaScript
- Stars
- 49.4k
- Forks
- 1.7k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 30
Description
I'm not entirely sure about the logic of the function `updateScrollState` at 2817 or I would propose a PR, but it doesn't seem to be working like I'd expect it to?
I'd expect `scroll:` or `show:` `top` with no passed element to scroll to the top of the page. However, HTMX does not seem to do that consistently in my testing, there's some interaction happening with sizing on the page or with the top element being fixed, I'm not sure which.
There does seem to be a clear fix, `show:top` or `scroll:top` when not passed a specific context or element to target should execute `window.scrollTo(0, 0);`. This works regardless of page configuration and does so consistently.
I will also note another strange behavior I'm not sure is intentional:
`show:top` will only execute [this condition](https://github.com/bigskysoftware/htmx/blob/145627a5792520b10f35e86eea23ce5c388e0fb0/src/htmx.js#L2843) but `scroll:top` appears to execute [the condition at line 2825](https://github.com/bigskysoftware/htmx/blob/145627a5792520b10f35e86eea23ce5c388e0fb0/src/htmx.js#L2825C31-L2825C31) and the above `show` condition.
Contributor guide
Assessment
This issue has not been assessed yet.