Skip to content

Commit

Permalink
fix!: do not validate login form fields on blur (#8101)
Browse files Browse the repository at this point in the history
  • Loading branch information
vursen authored Nov 7, 2024
1 parent 9d96d20 commit b9c6590
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/login/src/vaadin-lit-login-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class LoginForm extends LoginFormMixin(ElementMixin(ThemableMixin(PolylitMixin(L
autocorrect="off"
spellcheck="false"
autocomplete="username"
manual-validation
>
<input type="text" slot="input" @keyup="${this._handleInputKeyup}" />
</vaadin-text-field>
Expand All @@ -77,6 +78,7 @@ class LoginForm extends LoginFormMixin(ElementMixin(ThemableMixin(PolylitMixin(L
@keydown="${this._handleInputKeydown}"
spellcheck="false"
autocomplete="current-password"
manual-validation
>
<input type="password" slot="input" @keyup="${this._handleInputKeyup}" />
</vaadin-password-field>
Expand Down
2 changes: 2 additions & 0 deletions packages/login/src/vaadin-login-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class LoginForm extends LoginFormMixin(ElementMixin(ThemableMixin(PolymerElement
autocorrect="off"
spellcheck="false"
autocomplete="username"
manual-validation
>
<input type="text" slot="input" on-keyup="_handleInputKeyup" />
</vaadin-text-field>
Expand All @@ -88,6 +89,7 @@ class LoginForm extends LoginFormMixin(ElementMixin(ThemableMixin(PolymerElement
on-keydown="_handleInputKeydown"
spellcheck="false"
autocomplete="current-password"
manual-validation
>
<input type="password" slot="input" on-keyup="_handleInputKeyup" />
</vaadin-password-field>
Expand Down
10 changes: 10 additions & 0 deletions packages/login/test/dom/__snapshots__/login-form.test.snap.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ snapshots["vaadin-login-form host default"] =
focused=""
has-label=""
id="vaadinLoginUsername"
manual-validation=""
name="username"
required=""
spellcheck="false"
Expand Down Expand Up @@ -52,6 +53,7 @@ snapshots["vaadin-login-form host default"] =
autocomplete="current-password"
has-label=""
id="vaadinLoginPassword"
manual-validation=""
name="password"
required=""
spellcheck="false"
Expand Down Expand Up @@ -130,6 +132,7 @@ snapshots["vaadin-login-form host required"] =
has-label=""
id="vaadinLoginUsername"
invalid=""
manual-validation=""
name="username"
required=""
spellcheck="false"
Expand Down Expand Up @@ -168,6 +171,7 @@ snapshots["vaadin-login-form host required"] =
has-label=""
id="vaadinLoginPassword"
invalid=""
manual-validation=""
name="password"
required=""
spellcheck="false"
Expand Down Expand Up @@ -246,6 +250,7 @@ snapshots["vaadin-login-form host i18n"] =
focused=""
has-label=""
id="vaadinLoginUsername"
manual-validation=""
name="username"
required=""
spellcheck="false"
Expand Down Expand Up @@ -279,6 +284,7 @@ snapshots["vaadin-login-form host i18n"] =
autocomplete="current-password"
has-label=""
id="vaadinLoginPassword"
manual-validation=""
name="password"
required=""
spellcheck="false"
Expand Down Expand Up @@ -357,6 +363,7 @@ snapshots["vaadin-login-form host i18n-required"] =
has-label=""
id="vaadinLoginUsername"
invalid=""
manual-validation=""
name="username"
required=""
spellcheck="false"
Expand Down Expand Up @@ -395,6 +402,7 @@ snapshots["vaadin-login-form host i18n-required"] =
has-label=""
id="vaadinLoginPassword"
invalid=""
manual-validation=""
name="password"
required=""
spellcheck="false"
Expand Down Expand Up @@ -473,6 +481,7 @@ snapshots["vaadin-login-form host noForgotPassword"] =
focused=""
has-label=""
id="vaadinLoginUsername"
manual-validation=""
name="username"
required=""
spellcheck="false"
Expand Down Expand Up @@ -506,6 +515,7 @@ snapshots["vaadin-login-form host noForgotPassword"] =
autocomplete="current-password"
has-label=""
id="vaadinLoginPassword"
manual-validation=""
name="password"
required=""
spellcheck="false"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ snapshots["vaadin-login-overlay host default"] =
focused=""
has-label=""
id="vaadinLoginUsername"
manual-validation=""
name="username"
required=""
spellcheck="false"
Expand Down Expand Up @@ -66,6 +67,7 @@ snapshots["vaadin-login-overlay host default"] =
autocomplete="current-password"
has-label=""
id="vaadinLoginPassword"
manual-validation=""
name="password"
required=""
spellcheck="false"
Expand Down Expand Up @@ -157,6 +159,7 @@ snapshots["vaadin-login-overlay host i18n"] =
focused=""
has-label=""
id="vaadinLoginUsername"
manual-validation=""
name="username"
required=""
spellcheck="false"
Expand Down Expand Up @@ -190,6 +193,7 @@ snapshots["vaadin-login-overlay host i18n"] =
autocomplete="current-password"
has-label=""
id="vaadinLoginPassword"
manual-validation=""
name="password"
required=""
spellcheck="false"
Expand Down Expand Up @@ -282,6 +286,7 @@ snapshots["vaadin-login-overlay host overlay class"] =
focused=""
has-label=""
id="vaadinLoginUsername"
manual-validation=""
name="username"
required=""
spellcheck="false"
Expand Down Expand Up @@ -315,6 +320,7 @@ snapshots["vaadin-login-overlay host overlay class"] =
autocomplete="current-password"
has-label=""
id="vaadinLoginPassword"
manual-validation=""
name="password"
required=""
spellcheck="false"
Expand Down
18 changes: 18 additions & 0 deletions packages/login/test/login-form.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,24 @@ describe('login form', () => {
expect(spy.calledOnce).to.be.true;
});

it('should not validate username on blur', () => {
const { vaadinLoginUsername } = login.$;

vaadinLoginUsername.focus();
vaadinLoginUsername.blur();

expect(vaadinLoginUsername.invalid).to.be.false;
});

it('should not validate password on blur', () => {
const { vaadinLoginPassword } = login.$;

vaadinLoginPassword.focus();
vaadinLoginPassword.blur();

expect(vaadinLoginPassword.invalid).to.be.false;
});

it('should mark only username as invalid if user hits ENTER when field is empty', () => {
const { vaadinLoginUsername, vaadinLoginPassword } = login.$;

Expand Down

0 comments on commit b9c6590

Please sign in to comment.