From d0dde67c186f624b9e1ddaa6cfd03ae4d41b2d64 Mon Sep 17 00:00:00 2001 From: Knoobie Date: Mon, 23 Oct 2017 14:33:55 +0200 Subject: adds simple fix for missing label text in grid select checkboxes (#10223) * adds simple fix for missing label text in grid select checkboxes * updated comment and wording --- .../client/widget/grid/selection/MultiSelectionRenderer.java | 12 ++++++++++++ client/src/main/java/com/vaadin/client/widgets/Grid.java | 3 +++ 2 files changed, 15 insertions(+) (limited to 'client/src') diff --git a/client/src/main/java/com/vaadin/client/widget/grid/selection/MultiSelectionRenderer.java b/client/src/main/java/com/vaadin/client/widget/grid/selection/MultiSelectionRenderer.java index ba27d96afa..ebf806bbbd 100644 --- a/client/src/main/java/com/vaadin/client/widget/grid/selection/MultiSelectionRenderer.java +++ b/client/src/main/java/com/vaadin/client/widget/grid/selection/MultiSelectionRenderer.java @@ -604,6 +604,9 @@ public class MultiSelectionRenderer CheckBoxEventHandler handler = new CheckBoxEventHandler(checkBox); + // label of checkbox should only be visible for assistive devices + checkBox.addStyleName("v-assistive-device-only-label"); + // Sink events checkBox.sinkBitlessEvent(BrowserEvents.MOUSEDOWN); checkBox.sinkBitlessEvent(BrowserEvents.TOUCHSTART); @@ -623,9 +626,18 @@ public class MultiSelectionRenderer public void render(final RendererCellReference cell, final Boolean data, CheckBox checkBox) { checkBox.setValue(data, false); + // this should be a temp fix. + checkBox.setText("Selects row number " + getDOMRowIndex(cell) + "."); checkBox.setEnabled(grid.isEnabled() && !grid.isEditorActive()); } + private int getDOMRowIndex(RendererCellReference cell){ + // getRowIndex starts with zero, that's why we add an additional 1. + // getDOMRowIndex should include getHeaderRows as well, this number + // should be equals to aria-rowindex. + return cell.getGrid().getHeaderRowCount() + cell.getRowIndex() + 1; + } + @Override public Collection getConsumedEvents() { final HashSet events = new HashSet<>(); diff --git a/client/src/main/java/com/vaadin/client/widgets/Grid.java b/client/src/main/java/com/vaadin/client/widgets/Grid.java index 4651c534dc..73867caa72 100755 --- a/client/src/main/java/com/vaadin/client/widgets/Grid.java +++ b/client/src/main/java/com/vaadin/client/widgets/Grid.java @@ -2928,11 +2928,14 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, selectAllCheckBox = GWT.create(CheckBox.class); selectAllCheckBox.setStylePrimaryName( getStylePrimaryName() + SELECT_ALL_CHECKBOX_CLASSNAME); + // label of checkbox should only be visible for assistive devices + selectAllCheckBox.addStyleName("v-assistive-device-only-label"); selectAllCheckBox.addValueChangeHandler(event -> { selected = event.getValue(); fireEvent(new SelectAllEvent<>(getSelectionModel(), selected)); }); + selectAllCheckBox.setText("Selects all rows of the table."); selectAllCheckBox.setValue(selected); addHeaderClickHandler(this::onHeaderClickEvent); -- cgit v1.2.3