Hey Drew,
This being JS and all, there are plenty of ways to work around it. I’m trying to remember exactly what I did, but it would fall under the idea of:
Instead of referencing an (external) controller in an ancestor DOM element via data-controller, you can simply reference the (external) controller and its state/actions from within the (child) controller javacript.
For example, each row would have data-action=click->childController#doSomething". The childController#doSomething would then access parentController#doSomethingForChild.
Option 1:
It looks like Stimulus has a method specifically for this type of access - If you go to Stimulus Reference - scroll to the bottom section of “Directly Invoking other Controllers”.
You can then call methods on the (parent) controller and if you want, you can even introduce getter/setter methods if you want to manipulate state.
Option 2:
Same idea as Option 1 (I did this before I knew that Stimulus had introduced the getCotnrollerForElementAndIdentifier method), but you can create your own singleton index/hash for controllers which can be accessed by any controller. (ie. think of a global variable).
Note: You can also use custom events to avoid directly coupling controllers together which can be frowned upon but it really depends on the use case. If you’re finding yourself trying to access multiple external controllers, and order-of-operations doesn’t matter, then firing a custom event is likely the better solution.
Option 3: they should really fix this memory leak… I’ll see if I can get around to raising a defect for it.