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

Improve error message when duplicate keys are detected (in __DEV__) #1412

Open
SDRACK opened this issue Jun 11, 2024 · 3 comments
Open

Improve error message when duplicate keys are detected (in __DEV__) #1412

SDRACK opened this issue Jun 11, 2024 · 3 comments
Labels
🪄 enhancement New feature or request 🟡 priority-2 2. Medium priority issue

Comments

@SDRACK
Copy link

SDRACK commented Jun 11, 2024

Reproduction

https://formkit.link/4920b90204eb2a0437e463b81dc5e938

Describe the bug

This is a funny one - if an ID is added to a mask input in a repeater, when items are added they break.

I've not checked other input types, but it might apply beyond masks.

To replicate in the playground:

  1. at first, everything works as expected
  2. add a new item to the repeater
  3. the new item doesn't respect the mask nor populate the form data

In my opinion, this is a question of messaging more than anything else. Duplicated IDs are a bad thing so shouldn't be used, but the current situation of unexplained errors makes debugging the problem very difficult.

Would it be possible to add a console error / warning if IDs are added to repeaters, in order to make this a trivial fix?

Environment

• OS: Mac OS 14.5 (23F79)
• Browser: Chrome Version 125.0.6422.141
• Version: Formkit 1.6

@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 Jun 11, 2024
@justin-schroeder
Copy link
Member

Ids must always be globally unique (that's just an HTML thing).

@SDRACK
Copy link
Author

SDRACK commented Jun 12, 2024

Ids must always be globally unique (that's just an HTML thing).

Yeah, agree @justin-schroeder - my concern is around the visibility of the issue. It's a pretty straightforward mistake to make, but the error that occurs in FormKit is very unclear - things just stop working.

Would it be possible to add a Javascript error / warning if someone does this to explain what's happened, rather than have fields just fail as in the playground example?

@justin-schroeder
Copy link
Member

That seems like a reasonable thing to do. In general we try to not put too much additional weight into the bundle to guard for error messages, but we recently added a development build and I think we could improve the error messages that are displayed at development time. I’ll rename this issue to that effect.

@justin-schroeder justin-schroeder changed the title Mask inputs break when IDs are duplicated Improve error message when duplicate keys are detected (in __DEV__) Jun 12, 2024
@justin-schroeder justin-schroeder added 🪄 enhancement New feature or request 🟡 priority-2 2. Medium 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 Jun 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🪄 enhancement New feature or request 🟡 priority-2 2. Medium priority issue
Projects
None yet
Development

No branches or pull requests

2 participants