From a0ae13800027aa14cda3c67366e0a187707e1886 Mon Sep 17 00:00:00 2001 From: "TatuWorkLenovo\\Tatu" Date: Fri, 27 Dec 2024 16:08:13 +0200 Subject: [PATCH] feat: Add audible form closed announce chore: Remove un-necessary aria-label from overlay container --- .../tatu/vaadincreate/VaadinCreateUI.java | 7 ++++++- .../tatu/vaadincreate/crud/form/BookForm.java | 19 ++++++++++++++----- .../vaadin/tatu/vaadincreate/i18n/I18n.java | 1 + .../main/resources/translate_de_DE.properties | 1 + .../main/resources/translate_en_GB.properties | 1 + .../main/resources/translate_fi_FI.properties | 1 + 6 files changed, 24 insertions(+), 6 deletions(-) diff --git a/vaadincreate-ui/src/main/java/org/vaadin/tatu/vaadincreate/VaadinCreateUI.java b/vaadincreate-ui/src/main/java/org/vaadin/tatu/vaadincreate/VaadinCreateUI.java index 1e89dd1..f0d95f3 100644 --- a/vaadincreate-ui/src/main/java/org/vaadin/tatu/vaadincreate/VaadinCreateUI.java +++ b/vaadincreate-ui/src/main/java/org/vaadin/tatu/vaadincreate/VaadinCreateUI.java @@ -246,7 +246,12 @@ public void attach() { super.attach(); // Workaround: https://github.com/vaadin/framework/issues/5772 getPage().getJavaScript().execute( - "setTimeout(() => document.getElementsByClassName('v-tooltip')[0].style.zIndex=30001, 200);"); + """ + setTimeout(() => { + document.getElementsByClassName('v-tooltip')[0].style.zIndex=30001; + document.getElementsByClassName('v-overlay-container')[0].removeAttribute('aria-label'); + }, 200); + """); } /** diff --git a/vaadincreate-ui/src/main/java/org/vaadin/tatu/vaadincreate/crud/form/BookForm.java b/vaadincreate-ui/src/main/java/org/vaadin/tatu/vaadincreate/crud/form/BookForm.java index aa1789a..d2578f0 100644 --- a/vaadincreate-ui/src/main/java/org/vaadin/tatu/vaadincreate/crud/form/BookForm.java +++ b/vaadincreate-ui/src/main/java/org/vaadin/tatu/vaadincreate/crud/form/BookForm.java @@ -282,6 +282,9 @@ public void showForm(boolean visible) { clearDirtyIndicators(); } sidePanel.show(visible); + if (!visible) { + VaadinCreateUI.get().announce(getTranslation(I18n.CLOSED)); + } } public Product getProduct() { @@ -407,12 +410,10 @@ public void editProduct(Product product) { presenter.requestUpdateCategories(); if (product == null) { product = new Product(); + readProduct(product); + return; } - deleteButton.setEnabled(product.getId() != null); - currentProduct = product; - binder.readBean(product); - saveButton.setEnabled(false); - discardButton.setEnabled(false); + readProduct(product); // Scroll to the top // As this is not a Panel, using JavaScript @@ -426,6 +427,14 @@ public void editProduct(Product product) { announceProductOpened(product); } + private void readProduct(Product product) { + deleteButton.setEnabled(product.getId() != null); + currentProduct = product; + binder.readBean(product); + saveButton.setEnabled(false); + discardButton.setEnabled(false); + } + // This is horrible, but required to workaround a bug in NVDA private void announceProductOpened(Product product) { if (isAttached()) { diff --git a/vaadincreate-ui/src/main/java/org/vaadin/tatu/vaadincreate/i18n/I18n.java b/vaadincreate-ui/src/main/java/org/vaadin/tatu/vaadincreate/i18n/I18n.java index a3a0dd1..0c86096 100644 --- a/vaadincreate-ui/src/main/java/org/vaadin/tatu/vaadincreate/i18n/I18n.java +++ b/vaadincreate-ui/src/main/java/org/vaadin/tatu/vaadincreate/i18n/I18n.java @@ -34,6 +34,7 @@ private I18n() { public static final String CURRENT_PAGE = "current-page"; public static final String OPENED = "opened"; public static final String CONFIRM = "confirm"; + public static final String CLOSED = "closed"; public static final class Books { public static final String UPDATED = "updated"; diff --git a/vaadincreate-ui/src/main/resources/translate_de_DE.properties b/vaadincreate-ui/src/main/resources/translate_de_DE.properties index 6c4cf9b..2ff2adf 100644 --- a/vaadincreate-ui/src/main/resources/translate_de_DE.properties +++ b/vaadincreate-ui/src/main/resources/translate_de_DE.properties @@ -96,3 +96,4 @@ ready = bereit product-form = buchform opened = geöffnet current-page = aktuelle seite +closed = buchform geschlossen diff --git a/vaadincreate-ui/src/main/resources/translate_en_GB.properties b/vaadincreate-ui/src/main/resources/translate_en_GB.properties index eafe022..0a1697a 100644 --- a/vaadincreate-ui/src/main/resources/translate_en_GB.properties +++ b/vaadincreate-ui/src/main/resources/translate_en_GB.properties @@ -96,4 +96,5 @@ ready = ready product-form = bookform opened = opened current-page = current page +closed = product form closed diff --git a/vaadincreate-ui/src/main/resources/translate_fi_FI.properties b/vaadincreate-ui/src/main/resources/translate_fi_FI.properties index e8cfc2e..3ecd0a4 100644 --- a/vaadincreate-ui/src/main/resources/translate_fi_FI.properties +++ b/vaadincreate-ui/src/main/resources/translate_fi_FI.properties @@ -95,4 +95,5 @@ ready = valmis product-form = tuotelomake opened = avattu current-page = nykyinen sivu +closed = tuote lomake suljettu