diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index aa35df0b3..1de45b5c9 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,5 +1,5 @@ class ApplicationController < ActionController::Base - include Authentication, Authorization, CurrentRequest, CurrentTimezone, SetPlatform, TurboFlash, WriterAffinity + include Authentication, Authorization, CurrentRequest, CurrentTimezone, SetPlatform, TurboFlash, ViewTransitions, WriterAffinity stale_when_importmap_changes allow_browser versions: :modern, block: -> { render "errors/not_acceptable", layout: "error" } diff --git a/app/controllers/concerns/view_transitions.rb b/app/controllers/concerns/view_transitions.rb new file mode 100644 index 000000000..94b9c0a55 --- /dev/null +++ b/app/controllers/concerns/view_transitions.rb @@ -0,0 +1,16 @@ +module ViewTransitions + extend ActiveSupport::Concern + + included do + before_action :disable_view_transitions, if: :page_refresh? + end + + private + def disable_view_transitions + @disable_view_transition = true + end + + def page_refresh? + request.referrer.present? && request.referrer == request.url + end +end diff --git a/app/views/layouts/shared/_head.html.erb b/app/views/layouts/shared/_head.html.erb index 25b06cae9..4c88b0190 100644 --- a/app/views/layouts/shared/_head.html.erb +++ b/app/views/layouts/shared/_head.html.erb @@ -2,7 +2,10 @@ <%= page_title_tag %> - + + <% unless @disable_view_transition %> + + <% end %>