hotwire-livereload
hotwire-livereload copied to clipboard
Restoring Scrollposition after editing JS/CSS
Hi,
i have an issue with the scroll position.
After editing my JS or CSS Code it reloads the page without scrolling to the restored scroll position.
I only changed the listen_paths of the gem because im using postcss to:
config.hotwire_livereload.disable_default_listeners = true
config.hotwire_livereload.listen_paths = [Rails.root.join("app/assets/builds")]
My console output:
Could you please try disabling data-turbo-track for CSS like @mikker mentioned in #59?
+ <%= stylesheet_link_tag "application", "data-turbo-track": Rails.env.production? ? "reload" : "" %>
- <%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>
Okay i understand but now it restores the old styling and overwrite it with the new.
That's working for changes of styling but when you removing some, it's not working.
Had the same issue myself. Turbo now has a dynamic option that worked for me.
<%= stylesheet_link_tag "application", "data-turbo-track": "dynamic" %>
Perfekt, that fixed the Problem. Thankyou!
Switching to dynamic solved my gripe! I think that's actually better than the "are you in dev?" current setup
EDIT: my problem being my scroll resetting to the top of the page any time my Tailwind styles rebuilt
I wish there was a way to do some neat magic with Javascript to prevent reloads, but unfortunately when using import maps they bake in the turbo reload tag:
https://github.com/rails/importmap-rails/blob/cc7142e9996d441aa726eb6e013de29ff990ff60/app/helpers/importmap/importmap_tags_helper.rb#L15