Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'destroying' event doesn't fire on repeater element removal #1291

Open
SDRACK opened this issue Apr 3, 2024 · 1 comment
Open

'destroying' event doesn't fire on repeater element removal #1291

SDRACK opened this issue Apr 3, 2024 · 1 comment
Labels
🐛 bug Verified bug by team 🔵 priority-3 3. Lower priority issue

Comments

@SDRACK
Copy link

SDRACK commented Apr 3, 2024

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:

  1. Add an element to the repeater
  2. 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)

@SDRACK SDRACK added ⛑ Needs triage The issue has not yet been examined by the FormKit team. 🐛 bug-report Bug is reported, but not verified by team labels Apr 3, 2024
@justin-schroeder
Copy link
Member

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.

@justin-schroeder justin-schroeder added 🐛 bug Verified bug by team 🔵 priority-3 3. Lower priority issue and removed 🐛 bug-report Bug is reported, but not verified by team ⛑ Needs triage The issue has not yet been examined by the FormKit team. labels Apr 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Verified bug by team 🔵 priority-3 3. Lower priority issue
Projects
None yet
Development

No branches or pull requests

2 participants