From a48e0f54f4956f065eae27e6004e38b890dc8f0f Mon Sep 17 00:00:00 2001 From: Sean Doyle Date: Thu, 30 Nov 2023 21:30:08 -0500 Subject: [PATCH] Render full documents for requests with `Turbo-Frame:` header Re-submission of [#232][] Related to [hotwired/turbo#1047][] Render full documents, including default layout rendering behavior. Rendering a minimal layout forces `turbo:reload` events because of the severe difference in the contents of the minimal layout's `` and the requesting document's fully populated ``. [#232]: https://github.com/hotwired/turbo-rails/pull/232 [hotwired/turbo#1047]: https://github.com/hotwired/turbo/issues/1047 --- app/controllers/turbo/frames/frame_request.rb | 1 - app/views/layouts/turbo_rails/frame.html.erb | 8 -------- test/frames/frame_request_controller_test.rb | 4 ++-- yarn.lock | 4 ++-- 4 files changed, 4 insertions(+), 13 deletions(-) delete mode 100644 app/views/layouts/turbo_rails/frame.html.erb diff --git a/app/controllers/turbo/frames/frame_request.rb b/app/controllers/turbo/frames/frame_request.rb index 2063a28d..cb1015c8 100644 --- a/app/controllers/turbo/frames/frame_request.rb +++ b/app/controllers/turbo/frames/frame_request.rb @@ -21,7 +21,6 @@ module Turbo::Frames::FrameRequest extend ActiveSupport::Concern included do - layout -> { "turbo_rails/frame" if turbo_frame_request? } etag { :frame if turbo_frame_request? } helper_method :turbo_frame_request_id diff --git a/app/views/layouts/turbo_rails/frame.html.erb b/app/views/layouts/turbo_rails/frame.html.erb deleted file mode 100644 index 0171671e..00000000 --- a/app/views/layouts/turbo_rails/frame.html.erb +++ /dev/null @@ -1,8 +0,0 @@ - - - <%= yield :head %> - - - <%= yield %> - - diff --git a/test/frames/frame_request_controller_test.rb b/test/frames/frame_request_controller_test.rb index 71a12928..d80b26aa 100644 --- a/test/frames/frame_request_controller_test.rb +++ b/test/frames/frame_request_controller_test.rb @@ -6,7 +6,7 @@ class Turbo::FrameRequestControllerTest < ActionDispatch::IntegrationTest assert_select "title", count: 1 get tray_path(id: 1), headers: { "Turbo-Frame" => "true" } - assert_select "title", count: 0 + assert_select "title", count: 1 end test "frame request layout includes `head` content" do @@ -22,7 +22,7 @@ class Turbo::FrameRequestControllerTest < ActionDispatch::IntegrationTest end assert_select "meta[name=test][content=present]" - assert_select "meta[name=alternative][content=present]" + assert_select "meta[name=alternative][content=present]", count: 0 end test "frame requests get a unique etag" do diff --git a/yarn.lock b/yarn.lock index 577a92d7..e291dfce 100644 --- a/yarn.lock +++ b/yarn.lock @@ -206,9 +206,9 @@ hasown@^2.0.0: dependencies: function-bind "^1.1.2" -"idiomorph@git+https://github.com/basecamp/idiomorph.git#rollout-build": +"idiomorph@https://github.com/basecamp/idiomorph#rollout-build": version "0.0.8" - resolved "git+https://github.com/basecamp/idiomorph.git#e906820368e4c9c52489a3336b8c3826b1bf6de5" + resolved "https://github.com/basecamp/idiomorph#e906820368e4c9c52489a3336b8c3826b1bf6de5" is-core-module@^2.13.0: version "2.13.1"