Skip to content

Commit 2555126

Browse files
authored
Merge pull request #102 from inertiajs/fix-partial-rendering-after-deep-merge-changes
Fix partial reload rendering after deep merge changes
2 parents 6f249f1 + 7fa0510 commit 2555126

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

lib/inertia_rails/renderer.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def layout
4545
def computed_props
4646
_props = ::InertiaRails.shared_data(@controller).send(prop_merge_method, @props).select do |key, prop|
4747
if rendering_partial_component?
48-
key.in? partial_keys
48+
key.to_sym.in? partial_keys
4949
else
5050
!prop.is_a?(InertiaRails::Lazy)
5151
end

spec/inertia/rendering_spec.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464

6565
context 'partial rendering' do
6666
let (:page) {
67-
InertiaRails::Renderer.new('TestComponent', controller, request, response, '', props: { sport: 'hockey'}).send(:page)
67+
InertiaRails::Renderer.new('TestComponent', controller, request, response, '', props: { sport: 'hockey' }).send(:page)
6868
}
6969
let(:headers) {{
7070
'X-Inertia' => true,
@@ -76,6 +76,7 @@
7676
before { get props_path, headers: headers }
7777

7878
it { is_expected.to eq page.to_json }
79+
it { is_expected.to include('hockey') }
7980
end
8081

8182
context 'with a non matching partial component header' do
@@ -107,13 +108,16 @@
107108
}
108109
let(:headers) {{
109110
'X-Inertia' => true,
110-
'X-Inertia-Partial-Data' => 'sport,level,grit',
111+
'X-Inertia-Partial-Data' => 'sport,level',
111112
'X-Inertia-Partial-Component' => 'TestComponent',
112113
}}
113114

114115
before { get lazy_props_path, headers: headers }
115116

116117
it { is_expected.to eq page.to_json }
118+
it { is_expected.to include('basketball') }
119+
it { is_expected.to include('worse') }
120+
it { is_expected.not_to include('intense') }
117121
end
118122
end
119123
end

0 commit comments

Comments
 (0)