Hidden checkboxes are getting unchecked in case of validation error #3109
Replies: 4 comments
-
|
@squarebeard I think the problem is in realtime validation, the defer model is not suitable to be validated in the updated method, my suggestion is that the defer model is made separately as if it is validated when the form is submitted. |
Beta Was this translation helpful? Give feedback.
-
|
But why does it work when I change the CSS ? |
Beta Was this translation helpful? Give feedback.
-
|
@squarebeard not sure what you mean by changing the css "remove the display:none" as there is no styling on the sample you provided. @adeiming is correct, the way Livewire works, if there is multiple updates happening on the same request (for example a field is deferred), then when Livewire runs through its update cycle, it will try to update the properties in the original order they were changed. As you are running You should either make both have Hope this helps! |
Beta Was this translation helpful? Give feedback.
-
|
You missed the CSS in the head but anyway that made me do another example. Try the example, do you notice that the two checkboxes reacts differently ? |
Beta Was this translation helpful? Give feedback.

Uh oh!
There was an error while loading. Please reload this page.
-
This one is quite hard to describe but you can reproduce the problem here.
As you can see in the playground, there is a required text input and a checkbox. The text input use the "defer" modifier.
Now if you empty the text input then click on the checkbox, the validation will fail because the text is required but the problem is that the checkbox does not stay checked.
What I do not understand is that it can be fixed by changing the CSS. You'll notice that the checkbox is hidden and styled using CSS. If you remove the "display: none" it works as expected.
I can work around the bug by using other means of hiding the checkbox, like opacity. But I'm worried that this bug will happen again elsewhere, and it's quite hard to detect or predict.
Can someone explain what is happening ?
Beta Was this translation helpful? Give feedback.
All reactions