bigskysoftware / htmx

</> htmx - high power tools for HTML
https://htmx.org
Other
38.1k stars 1.29k forks source link

Preserve scroll on swap content #2953

Open gerbil opened 2 weeks ago

gerbil commented 2 weeks ago

I've tried both hx-swap="focus-scroll:true" and <meta name="htmx-config" content='{"defaultFocusScroll": true}'>, but still got scroll back to top on every table body triggered refresh event.

Is there any way to preserve scroll for specific content part after swap?

MichaelWest22 commented 2 weeks ago

Some things to check is that the element you want to retain its focus and scroll is one of the supported elements like an input and that you have it in focus and also it must have a id attached for the feature to work.

gerbil commented 2 weeks ago

It's a TR in TABLE; So generally hx-swap="show:#id:top" is working for static elements; But for dynamic lists now i need: