Skip to content

Commit

Permalink
fix: Workaroind NVDA bug, now the aria-live region is consistently an…
Browse files Browse the repository at this point in the history
…nounced
  • Loading branch information
TatuJLund committed Nov 24, 2024
1 parent f07d070 commit b74a718
Showing 1 changed file with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -423,11 +423,23 @@ public void editProduct(Product product) {
Page.getCurrent().getJavaScript().execute(scrollScript);
}

// Set ARIA attributes for the form to make it accessible
selectionLabel.setValue(String.format(
"<div role='alert' aria-live='polite' aria-label='%s %s'></div>",
product.getProductName(), getTranslation(I18n.Books.OPENED)));
announceProductOpened(product);
}

// This is horrible, but required to workaround a bug in NVDA
private void announceProductOpened(Product product) {
if (isAttached()) {
var prod = product;
selectionLabel.setValue("");
getUI().push();
getUI().runAfterRoundTrip(() -> {
// Set ARIA attributes for the form to make it accessible
selectionLabel.setValue(String.format(
"<div role='alert' aria-live='assertive' aria-atomic='true' aria-label='%s %s'></div>",
prod.getProductName(),
getTranslation(I18n.Books.OPENED)));
});
}
}

@Override
Expand Down

0 comments on commit b74a718

Please sign in to comment.