Closed WozniakMac closed 3 years ago
Sadly, the premise of your issue is flawed in the context of how SR is designed and (as you have confirmed) how it works.
Please understand that I am not happy to tell you this; I'd far prefer that this was a bug.
However, the two things you're wanting to do are indeed mutually exclusive; you can either replace an element or raise an event from a Stimulus controller instance on that DOM element... but not both. That's because the instance of the Stimulus controller you're expecting to hear from will no longer exist.
Hopefully, this confirmation will free you to try other design approaches in your application.
Bug Report
Describe the bug
When you call the reflex to remove clicked element from
dom
,afterReflex
callback won't ba called.I suspect it's because
element
indispatchLifecycleEvent
on stagefinalize
isnull
. Because of this, my loading spinner is not stopping.To Reproduce
show.html.erb
test_reflex.rb
application_controller.js
My example with modal https://github.com/hopsoft/stimulus_reflex_expo/compare/master...WozniakMac:bug-repoduction-remove-action-element-reflex#diff-f0f6e190c54120fc0d7c11be7de363c7035cb8e9ce35fa1a5a8ac3a48881814cR21-R23
Expected behavior
I should be able to call
afterReflex
even if the element is removed.Screenshots or reproduction
Versions
StimulusReflex
External tools
Browser