Skip to content

Commit

Permalink
fix: set hidden attribute on the error message when field is valid (#…
Browse files Browse the repository at this point in the history
…3143) (#3147)

Co-authored-by: David Sosa <[email protected]>
  • Loading branch information
vaadin-bot and sosa-vaadin authored Dec 2, 2021
1 parent b668e9b commit 1016a88
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,10 @@ snapshots["vaadin-email-field shadow theme"] =
snapshots["vaadin-email-field slots default"] =
`<label slot="label">
</label>
<div slot="error-message">
<div
hidden=""
slot="error-message"
>
</div>
<input
autocapitalize="off"
Expand All @@ -244,7 +247,10 @@ snapshots["vaadin-email-field slots default"] =
snapshots["vaadin-email-field slots helper"] =
`<label slot="label">
</label>
<div slot="error-message">
<div
hidden=""
slot="error-message"
>
</div>
<input
autocapitalize="off"
Expand Down
1 change: 1 addition & 0 deletions packages/field-base/src/field-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ export const FieldMixin = (superclass) =>
}
const hasError = Boolean(invalid && errorMessage);
error.textContent = hasError ? errorMessage : '';
error.hidden = !hasError;
this.toggleAttribute('has-error-message', hasError);

// Role alert will make the error message announce immediately
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,10 @@ snapshots["vaadin-integer-field shadow theme"] =
snapshots["vaadin-integer-field slots default"] =
`<label slot="label">
</label>
<div slot="error-message">
<div
hidden=""
slot="error-message"
>
</div>
<input
max="undefined"
Expand All @@ -359,7 +362,10 @@ snapshots["vaadin-integer-field slots default"] =
snapshots["vaadin-integer-field slots helper"] =
`<label slot="label">
</label>
<div slot="error-message">
<div
hidden=""
slot="error-message"
>
</div>
<input
max="undefined"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ snapshots["vaadin-message-input default"] =
`<vaadin-message-input-text-area placeholder="Message">
<label slot="label">
</label>
<div slot="error-message">
<div
hidden=""
slot="error-message"
>
</div>
<textarea
aria-label="Message"
Expand Down Expand Up @@ -34,7 +37,10 @@ snapshots["vaadin-message-input disabled"] =
>
<label slot="label">
</label>
<div slot="error-message">
<div
hidden=""
slot="error-message"
>
</div>
<textarea
aria-label="Message"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,10 @@ snapshots["vaadin-number-field shadow theme"] =
snapshots["vaadin-number-field slots default"] =
`<label slot="label">
</label>
<div slot="error-message">
<div
hidden=""
slot="error-message"
>
</div>
<input
max="undefined"
Expand All @@ -359,7 +362,10 @@ snapshots["vaadin-number-field slots default"] =
snapshots["vaadin-number-field slots helper"] =
`<label slot="label">
</label>
<div slot="error-message">
<div
hidden=""
slot="error-message"
>
</div>
<input
max="undefined"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,10 @@ snapshots["vaadin-password-field shadow theme"] =
snapshots["vaadin-password-field slots default"] =
`<label slot="label">
</label>
<div slot="error-message">
<div
hidden=""
slot="error-message"
>
</div>
<button
aria-label="Show password"
Expand All @@ -287,7 +290,10 @@ snapshots["vaadin-password-field slots default"] =
snapshots["vaadin-password-field slots helper"] =
`<label slot="label">
</label>
<div slot="error-message">
<div
hidden=""
slot="error-message"
>
</div>
<button
aria-label="Show password"
Expand Down
10 changes: 8 additions & 2 deletions packages/select/test/dom/__snapshots__/select.test.snap.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,10 @@ snapshots["vaadin-select shadow theme"] =
snapshots["vaadin-select slots default"] =
`<label slot="label">
</label>
<div slot="error-message">
<div
hidden=""
slot="error-message"
>
</div>
<vaadin-select-value-button
aria-expanded="false"
Expand All @@ -238,7 +241,10 @@ snapshots["vaadin-select slots default"] =
snapshots["vaadin-select slots helper"] =
`<label slot="label">
</label>
<div slot="error-message">
<div
hidden=""
slot="error-message"
>
</div>
<vaadin-select-value-button
aria-expanded="false"
Expand Down
10 changes: 8 additions & 2 deletions packages/text-area/test/dom/__snapshots__/text-area.test.snap.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,10 @@ snapshots["vaadin-text-area shadow theme"] =
snapshots["vaadin-text-area slots default"] =
`<label slot="label">
</label>
<div slot="error-message">
<div
hidden=""
slot="error-message"
>
</div>
<textarea slot="textarea">
</textarea>
Expand All @@ -241,7 +244,10 @@ snapshots["vaadin-text-area slots default"] =
snapshots["vaadin-text-area slots helper"] =
`<label slot="label">
</label>
<div slot="error-message">
<div
hidden=""
slot="error-message"
>
</div>
<textarea slot="textarea">
</textarea>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,10 @@ snapshots["vaadin-text-field shadow theme"] =
snapshots["vaadin-text-field slots default"] =
`<label slot="label">
</label>
<div slot="error-message">
<div
hidden=""
slot="error-message"
>
</div>
<input
slot="input"
Expand All @@ -243,7 +246,10 @@ snapshots["vaadin-text-field slots default"] =
snapshots["vaadin-text-field slots helper"] =
`<label slot="label">
</label>
<div slot="error-message">
<div
hidden=""
slot="error-message"
>
</div>
<input
slot="input"
Expand Down

0 comments on commit 1016a88

Please sign in to comment.