From ba76f5660bc74fc7a96b93944a79f95366c53b8d Mon Sep 17 00:00:00 2001 From: michaelvogt Date: Thu, 5 Sep 2013 10:10:37 +0200 Subject: [PATCH] Prevent exception in VWindow without assistive description (#12515) Change-Id: Id16584ac2aec95981de31d713b56de42ca0cfae2 --- client/src/com/vaadin/client/ui/VWindow.java | 30 +++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/client/src/com/vaadin/client/ui/VWindow.java b/client/src/com/vaadin/client/ui/VWindow.java index 18df2222a4..03ad8d03c8 100644 --- a/client/src/com/vaadin/client/ui/VWindow.java +++ b/client/src/com/vaadin/client/ui/VWindow.java @@ -1323,6 +1323,8 @@ public class VWindow extends VWindowOverlay implements * Allows to specify which connectors contain the description for the * window. Text contained in the widgets of the connectors will be read by * assistive devices when it is opened. + *

+ * When the provided array is empty, an existing description is removed. * * @param connectors * with the connectors of the widgets to use as description @@ -1331,20 +1333,26 @@ public class VWindow extends VWindowOverlay implements if (connectors != null) { assistiveConnectors = connectors; - Id[] ids = new Id[connectors.length]; - for (int index = 0; index < connectors.length; index++) { - if (connectors[index] == null) { - throw new IllegalArgumentException( - "All values in parameter description need to be non-null"); + if (connectors.length == 0) { + Roles.getDialogRole().removeAriaDescribedbyProperty( + getElement()); + } else { + Id[] ids = new Id[connectors.length]; + for (int index = 0; index < connectors.length; index++) { + if (connectors[index] == null) { + throw new IllegalArgumentException( + "All values in parameter description need to be non-null"); + } + + Element element = ((ComponentConnector) connectors[index]) + .getWidget().getElement(); + AriaHelper.ensureHasId(element); + ids[index] = Id.of(element); } - Element element = ((ComponentConnector) connectors[index]) - .getWidget().getElement(); - AriaHelper.ensureHasId(element); - ids[index] = Id.of(element); + Roles.getDialogRole().setAriaDescribedbyProperty(getElement(), + ids); } - - Roles.getDialogRole().setAriaDescribedbyProperty(getElement(), ids); } else { throw new IllegalArgumentException( "Parameter description must be non-null"); -- 2.39.5