[vaadin-checkbox] Is always propagated in a login form's custom area
Description
Adding a CheckBox to a Login Overlay's custom area always sends the value to the server - even tho the checkbox is unchecked / never clicked. It does not matter if I use the default value of "on" or a custom value - the value is always send to the server, making the CheckBox useless.
Expected outcome
CheckBox's value is only send if the checkbox is checked.
Minimal reproducible example
LoginOverlay loginOverlay = new LoginOverlay();
var checkbox = new Checkbox("Test");
checkbox.getElement().setAttribute("name", "test");
loginOverlay.getCustomFormArea().add(checkbox);
Steps to reproduce
- Fill out form
- Press Submit
- See network tab: request contains test=on (even tho the checkbox is NOT checked)
Environment
Vaadin version(s): latest
The on is a default value that checkbox has. In native <form> it isn't submitted when unchecked, see MDN docs.
We should update the following logic in LoginMixin to detect the unchecked checkbox and don't submit it:
https://github.com/vaadin/web-components/blob/79ecca94f4b0dca53e860100b2b0ccaea1b42e42/packages/login/src/vaadin-login-form-mixin.js#L65-L67
In native form it isn't submitted when unchecked, see MDN docs.
Thanks! That was exactly the page I was also consulting which left me wondering why the form contained the value :)