'destroying' event doesn't fire on repeater element removal
SDRACK opened this issue · comments
Reproduction
https://formkit.link/aee1447c75108ab3f5df37f6ce611d4c
Describe the bug
Hiya all, hope you're doing good!
Got a quirky one - might be I've an X/Y problem, so happy to receive advice, but might also have clocked a little bug while in here.
We're looking to manage FormKit validation errors alongside some of our own, custom errors. To do so, we're using some events to plug FormKit errors into a Javascript Map.
In order to clear obsolete validation errors, I'm using the destroying
event (as well as message-removed
, but that's probably not relevant here).
This works nicely 90% of the time - e.g. if fields are shown conditionally and the condition changes, their errors are cleared out.
The problem is removing items from a repeater - this doesn't appear to emit the destroying
event, meaning we're left with lingering error messages.
To reproduce in the attached playground:
- Add an element to the repeater
- Delete that element from the repeater
Result: the deleted element's error message still shows in the formErrors
Map as it wasn't removed via the destroying
callback.
Personally speaking I'd have expected the destroying
event to fire when repeater items are removed?
(An aside - if this is all a result of us abusing the events / callback system, do let me know and I'll adjust as you advise!)
Thanks in advance,
Steve.
Environment
• OS: Sonoma 14.2.1 (23C71)
• Browser: Chrome
• Version: 122.0.6261.129 (Official Build) (arm64)
I see what you’re saying. The logic behind these dynamic lists is quite complex, so I cannot immediately identify what could be the culprit, but its worth looking into. thanks for the report.