Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Hotwire Reloading issue #113

Closed

Conversation

sarvaiyanidhi
Copy link
Contributor

@sarvaiyanidhi sarvaiyanidhi commented Mar 7, 2024

Fixes issue #99

Followed below steps for debugging Hotwire reloading issue

  • Theme not getting loaded in existing mode when we change file
    On debugging on this issue, it seems like it is due to below code added in layout

<%= turbo_refreshes_with method: :morph, scroll: :preserve %>

On commenting this line, theme is getting loaded correctly in its set mode.

Also this issue on morph kirillplatonov/hotwire-livereload#33 seems to be related.

  • Tailwind changes not reflecting every time on file change

On inspecting in browser console, it seems like at times we are facing with turbo link preload issue due to which changes does not get reflected in browser. To fix this issue I have added below code in development.rb. By adding below code it does not throw now issue of "the resource was preloaded using link preload but not used within a few seconds from the window's load event. Please make sure it has an appropriate as value and it is preloaded intentionally"

config.action_view.preload_links_header = false

Referred this link for this issue https://stackoverflow.com/questions/72753525/rails-turbo-link-preload-but-not-used-within-a-few-seconds-from-the-windows/72901033#72901033

Copy link
Contributor

@tjbarber tjbarber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Marking this as Request changes for now so this doesn't get prematurely merged.

<%= hotwire_livereload_tags if Rails.env.development? %>

<%= turbo_refreshes_with method: :morph, scroll: :preserve %>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @sarvaiyanidhi, we definitely want to keep turbo_refreshes_with method: :morph, scroll: :preserve. Morphing is a really cool feature of Turbo 8 that's we're going to want to utilize.

Is it possible to fix this issue with just the config.action_view.preload_links_header change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @tjbarber for feedback.

By just adding config.action_view.preload_links_header fixes Tailwind changes not reflecting every time on file change but theme issue still persist.

I believe theme old value is not getting retained due to morph code. I understand that we need this feature for the application but on checking further it seems like it is already identified issue. Came across related issues on the same hotwired/turbo#1210

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @sarvaiyanidhi ! We talked this one over and we think it's best to actually pursue an entirely different solution for theme switching altogether. We're considering options like persisting the state on some sort of user_settings table that we still have to map out. Thanks for putting time into this! Would you close this PR? I will close the issue as obsolete for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noted. Will close this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants