You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
when a record is destroyed make sure all "reactivity" is turned off during the update #195
context"updating a has_many relationship"dobefore(:each)dom=FactoryBot.create(:test_model,test_attribute: 'hello')FactoryBot.create(:child_model,test_model: m)mount"TestComponent3"doclassInnerComponent < HyperComponentparam:childrender{LI{"child id = #{@Child.id}#{@Child.test_model.test_attribute}"}}endclassTestComponent3 < HyperComponentrender(OL)doTestModel.all[0].child_models.eachdo |child|
InnerComponent(child: child)endendendendpage.shouldhave_content('child id = 1')endit"will update when sent from the server"doChildModel.create(child_attribute: :foo,test_model: TestModel.find(1))page.shouldhave_content('child id = 2')ChildModel.find(1).destroysleep0.1# necessary for poltergeist to work with pusher fakerpage.should_nothave_content('child id = 1',wait: 2)page.shouldhave_content('child id = 2')endend
because InnerComponent accesses the child's test_model, which is set to nil when the child is destroyed (because we want to keep all the linkages nicely synchronized) but setting this to nil causes the component to re-rerender.
Note that simply wrapping the destroy_associations method with the Base.loading method will not work, as this will turn off notification for both sides of the relationship. I.e. the has_many side will never re-render either, which it should.
Activity
closes #195
catmando commentedon Jun 12, 2019
FYI above patch is equivilent to the tested code.
closes hyperstack-org#195