diff --git a/libs/components/src/lib/date-range-picker/ui.test.ts b/libs/components/src/lib/date-range-picker/ui.test.ts index 896ba10f25..e751adc66e 100644 --- a/libs/components/src/lib/date-range-picker/ui.test.ts +++ b/libs/components/src/lib/date-range-picker/ui.test.ts @@ -185,7 +185,7 @@ test.describe('constraints validation', async () => { await expect( page.locator('vwc-date-range-picker .error-message') - ).toBeVisible(); + ).not.toHaveClass(/sr-only/); }); test('should hide a validation error after resetting the form', async ({ @@ -206,6 +206,6 @@ test.describe('constraints validation', async () => { await expect( page.locator('vwc-date-range-picker .error-message') - ).not.toBeVisible(); + ).toHaveClass(/sr-only/); }); }); diff --git a/libs/components/src/shared/patterns/form-elements/form-elements.spec.ts b/libs/components/src/shared/patterns/form-elements/form-elements.spec.ts index 7b0195f39f..91c03b0d05 100644 --- a/libs/components/src/shared/patterns/form-elements/form-elements.spec.ts +++ b/libs/components/src/shared/patterns/form-elements/form-elements.spec.ts @@ -347,7 +347,7 @@ describe('getFeedbackTemplate', () => { const getMessage = (type: string) => { const messageEl = element.shadowRoot!.querySelector( - `.${type}-message.message--visible` + `.${type}-message.message--visible:not(.sr-only)` ); if (!messageEl) { return null; diff --git a/libs/components/src/shared/patterns/form-elements/form-elements.ts b/libs/components/src/shared/patterns/form-elements/form-elements.ts index f1ab6a6645..772e5f8b14 100644 --- a/libs/components/src/shared/patterns/form-elements/form-elements.ts +++ b/libs/components/src/shared/patterns/form-elements/form-elements.ts @@ -176,6 +176,7 @@ type FeedbackConfig = { name: string; slottedContentProperty: '_helperTextSlottedContent'; }; + role: 'status' | 'none'; }; const feedback: Record = { helper: { @@ -185,16 +186,19 @@ const feedback: Record = { name: 'helper-text', slottedContentProperty: '_helperTextSlottedContent', }, + role: 'none', }, error: { messageProperty: 'errorValidationMessage', className: 'error', iconType: 'info-line', + role: 'status', }, success: { messageProperty: 'successText', className: 'success', iconType: 'check-circle-line', + role: 'none', }, }; @@ -249,10 +253,14 @@ function getFeedbackTypeTemplate( return html`
${when( (x) => shouldShow(x) && config.iconType, diff --git a/libs/components/src/shared/patterns/form-elements/message.scss b/libs/components/src/shared/patterns/form-elements/message.scss index 3003991f21..c98a35cfee 100644 --- a/libs/components/src/shared/patterns/form-elements/message.scss +++ b/libs/components/src/shared/patterns/form-elements/message.scss @@ -2,6 +2,16 @@ $low-ink-color: --_low-ink-color; +.sr-only { + position: absolute; + overflow: hidden; + width: 1px; + height: 1px; + clip: rect(0 0 0 0); + clip-path: inset(50%); + white-space: nowrap; +} + .message { display: none; contain: inline-size;