bigskysoftware / htmx

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

Preserve scroll on swap content #2953

Closed gerbil closed 1 month ago

gerbil commented 1 month 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 1 month 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 1 month 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:

gerbil commented 1 month ago

So the only possible option is `idiomorph' extension usage. Will try to stick with it.