Repository navigation
fix: prevent duplicate error message announcement when using NVDA - #3182
Conversation
|
Kudos, SonarCloud Quality Gate passed!
|
tomivirkki
left a comment
There was a problem hiding this comment.
Confirmed that the change fixes the issue on NVDA. Didn't notice any regressions on other screen readers.
| // 1. Once adding the `[role=alert]` attribute by the `_updateErrorMessage` method (OK). | ||
| // 2. Once linking the error ID with the ARIA target here (unwanted). | ||
| // Related issue: https://github.com/vaadin/web-components/issues/3061. | ||
| setTimeout(() => { |
There was a problem hiding this comment.
Let's use Debouncer to handle case when field becomes invalid and then immediately valid.
There was a problem hiding this comment.
After thinking it over, I’m not sure if there is a real problem. The first callback will be postponed, but the possible second callback seems to be only executed after the first one because setTimeout(() => ..., 0) places the callback to the event loop queue that keeps the order.
The following test case passes even in the current implementation:
it('should not contain error id after consecutive invalid/valid', async () => {
element.invalid = true;
element.invalid = false;
await aTimeout(0);
const aria = input.getAttribute('aria-labelledby');
expect(aria).to.include(label.id);
expect(aria).to.include(helper.id);
expect(aria).to.not.include(error.id);
});|
This ticket/PR has been released with platform 23.0.0.alpha1 and is also targeting the upcoming stable 23.0.0 version. |








Description
The PR introduces a workaround for
FieldMixinthat prevents double error message announcement when using NVDA, occurring as a side-effect of linking the error id to the ARIA target element. From now on, the error message is announced once and only when the[role=alert]attribute is added to the slotted error element.The workaround is to add a
setTimeoutdelay before linking the error id to the ARIA target element. This is the only workaround I was able to find. For the record, I triedrequestAnimationFrameandnew Promise((resolve) => resolve()), but they didn't work.Fixes #3061
Type of change
Checklist