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
I have data-turbo-permanent on a text field within a form. When the page updates, the permanent element remains and the stimulus controller disconnects and connects. I know this is the expected behavior and normally it works fine.
However, here is the issue:
When my connect() method first runs, it finds the text field by referencing this.inputTarget. But when the page morphs and the stimulus controller disconnects and calls connect() the second time, the this.inputTarget fails with:
Error: Missing target element "input" for "search" controller
I fixed the error by changing from connect() to inputTargetConnected(). But this should not fix the issue according to the stimulus docs. The connect() method is supposed to fire after the individual target connect methods.
The text was updated successfully, but these errors were encountered:
krschacht
changed the title
Bad interaction between data-turbo-permanent with stimulus lifecycle
stimulus connect() is being called out of order on reload with data-turbo-permanent
Dec 10, 2024
I have
data-turbo-permanent
on a text field within a form. When the page updates, the permanent element remains and the stimulus controller disconnects and connects. I know this is the expected behavior and normally it works fine.However, here is the issue:
When my
connect()
method first runs, it finds the text field by referencingthis.inputTarget
. But when the page morphs and the stimulus controller disconnects and callsconnect()
the second time, thethis.inputTarget
fails with:I fixed the error by changing from connect() to
inputTargetConnected()
. But this should not fix the issue according to the stimulus docs. The connect() method is supposed to fire after the individual target connect methods.The text was updated successfully, but these errors were encountered: