Validation errors in programmatically-set array items do not show up#641
Validation errors in programmatically-set array items do not show up#641jiehanzheng wants to merge 1 commit intojdorn:masterfrom
Conversation
|
Is this bug specific to the bootstrap themes? I'm wondering if there is a more general way to fix this without adding the same block of code to every theme file. The wait queue logic could potentially be added to theme.js which all the other themes inherit from. |
|
Yep -- I believe so. The root cause is I do agree, though, that duplicating the same code isn't great. theme.js makes sense, but I doubt we can envision all the possible dependencies that every theme will need, and handle the wait queue correctly in a generic way. Perhaps we can have themes call a getter and get back a promise? Although that sounds like an overkill. |
The bug may appear when the following conditions are met:
minLength) on array itemssetValue()bootstrap2orbootstrap3One would expect the validation error to show next to the input field, after using
setValue().The current, unexpected behavior is that validation errors do not show up.
This is because the array items are inserted on-the-fly, and the
input.controlgroupproperty may not be ready fast enough, causingaddInputErrorfunction in the theme to simply return without inserting the error class and error message.Reproduce this problem on...
JSFiddle
"minLength": 100is added toroot.parent, which displays just fine because it is ready early enough; however,root.children.0.child_propdid not have any errors displayed)Demo page: since this is a rare race condition, some work is needed to reproduce it. Use this as the base, and copy and paste the following into the data textarea, and hit Update Form.
{ "parent": "bad value", "children": [ { "child_prop": "also bad" } ] }More often than not you will not see any errors below the input field for the child.
This PR attempts to fix the problem by adding a wait queue of callbacks that depend on
input.controlgroupto be ready. When it is actually ready, callbacks on the queue, includingaddInputError, will be executed.