From 8a6e1bc73ae4f1c6725fa26e1a9a42d2ff2d468e Mon Sep 17 00:00:00 2001 From: Lucas Fernando Date: Wed, 1 Oct 2025 23:14:07 -0300 Subject: [PATCH 1/4] fix outdated settings related to default layout preview --- docs/guide/previews.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guide/previews.md b/docs/guide/previews.md index f6be4a681..1ba738711 100644 --- a/docs/guide/previews.md +++ b/docs/guide/previews.md @@ -110,7 +110,7 @@ To set a custom layout for individual previews and the previews index page, set: ```ruby # config/application.rb # Set the default layout to app/views/layouts/component_preview.html.erb -config.view_component.default_preview_layout = "component_preview" +config.view_component.previews.default_layout = "component_preview" ``` ## Preview paths From b904478c2c25eaa03dd6bf162a31005ae761b247 Mon Sep 17 00:00:00 2001 From: Lucas Geron Date: Wed, 1 Oct 2025 23:35:14 -0300 Subject: [PATCH 2/4] added a changelog entry --- docs/CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index e6bb654e2..3927607a8 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -9,6 +9,9 @@ nav_order: 6 # Changelog ## main +* Fix outdated settings related to default layout preview. + + *Lucas Geron* ## 4.0.2 From 103729b17cabd582da8de39ab0039c6c4343b1e3 Mon Sep 17 00:00:00 2001 From: Lucas Geron Date: Wed, 1 Oct 2025 23:35:14 -0300 Subject: [PATCH 3/4] added a changelog entry --- docs/CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index e6bb654e2..65ff3a9b2 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -10,6 +10,10 @@ nav_order: 6 ## main +* Fix outdated settings related to default layout preview. + + *Lucas Geron* + ## 4.0.2 * Share the view context in tests to prevent out-of-order rendering issues for certain advanced use-cases, eg. testing instances of Rails' `FormBuilder`. From c81c55028d90eb05d7c9efede25c50f1aba3d15b Mon Sep 17 00:00:00 2001 From: Lucas Geron Date: Wed, 1 Oct 2025 23:53:11 -0300 Subject: [PATCH 4/4] fix lint offenses --- lib/generators/view_component/component/component_generator.rb | 2 +- lib/view_component/collection.rb | 1 + lib/view_component/inline_template.rb | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/generators/view_component/component/component_generator.rb b/lib/generators/view_component/component/component_generator.rb index 0cce03808..60964c285 100644 --- a/lib/generators/view_component/component/component_generator.rb +++ b/lib/generators/view_component/component/component_generator.rb @@ -23,7 +23,7 @@ class ComponentGenerator < Rails::Generators::NamedBase class_option :skip_suffix, type: :boolean, default: false def create_component_file - template "component.rb", File.join(component_path, class_path, "#{file_name}#{options[:skip_suffix] ? "" : "_component"}.rb") + template "component.rb", File.join(component_path, class_path, "#{file_name}#{"_component" unless options[:skip_suffix]}.rb") end hook_for :test_framework diff --git a/lib/view_component/collection.rb b/lib/view_component/collection.rb index b76eeea1a..c53f1f1af 100644 --- a/lib/view_component/collection.rb +++ b/lib/view_component/collection.rb @@ -5,6 +5,7 @@ module ViewComponent class Collection include Enumerable + attr_reader :component delegate :size, to: :@collection diff --git a/lib/view_component/inline_template.rb b/lib/view_component/inline_template.rb index 06152e99b..95bb2acac 100644 --- a/lib/view_component/inline_template.rb +++ b/lib/view_component/inline_template.rb @@ -3,6 +3,7 @@ module ViewComponent # :nodoc: module InlineTemplate extend ActiveSupport::Concern + Template = Struct.new(:source, :language, :path, :lineno) class_methods do