From 9d1864b707a34d85139d4bea1dc99da930932a31 Mon Sep 17 00:00:00 2001 From: Felipe Lang Date: Fri, 19 Jan 2024 09:55:58 -0300 Subject: [PATCH] fix: hide grid selection column using JavaScript Hiding grid selection column with CSS breaks keyboard navigation Close #156 --- .../addons/twincolgrid/TwinColGrid.java | 4 ++-- .../frontend/styles/multiselect-cb-hide.css | 23 ------------------- 2 files changed, 2 insertions(+), 25 deletions(-) delete mode 100644 src/main/resources/META-INF/resources/frontend/styles/multiselect-cb-hide.css diff --git a/src/main/java/com/flowingcode/vaadin/addons/twincolgrid/TwinColGrid.java b/src/main/java/com/flowingcode/vaadin/addons/twincolgrid/TwinColGrid.java index 167b788..149aeb4 100644 --- a/src/main/java/com/flowingcode/vaadin/addons/twincolgrid/TwinColGrid.java +++ b/src/main/java/com/flowingcode/vaadin/addons/twincolgrid/TwinColGrid.java @@ -75,7 +75,6 @@ @SuppressWarnings("serial") @JsModule(value = "./src/fc-twin-col-grid-auto-resize.js") -@CssImport(value = "./styles/multiselect-cb-hide.css", themeFor = "vaadin-grid") @CssImport(value = "./styles/twin-col-grid-button.css") @CssImport(value = "./styles/twincol-grid.css") public class TwinColGrid extends VerticalLayout @@ -866,7 +865,8 @@ public FilterableTwinColumn addFilterableColumn(ItemLabelGenerator itemLab public TwinColGrid selectRowOnClick() { forEachGrid( grid -> { - grid.addClassName("hide-selector-col"); + grid.getElement().executeJs( + "if (this.querySelector('vaadin-grid-flow-selection-column')) { this.querySelector('vaadin-grid-flow-selection-column').hidden = true }"); grid.addItemClickListener( c -> { diff --git a/src/main/resources/META-INF/resources/frontend/styles/multiselect-cb-hide.css b/src/main/resources/META-INF/resources/frontend/styles/multiselect-cb-hide.css deleted file mode 100644 index e78f0dd..0000000 --- a/src/main/resources/META-INF/resources/frontend/styles/multiselect-cb-hide.css +++ /dev/null @@ -1,23 +0,0 @@ -/*- - * #%L - * TwinColGrid add-on - * %% - * Copyright (C) 2017 - 2022 Flowing Code - * %% - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * #L% - */ - -:host(.hide-selector-col) [part~="cell"][first-column] { - display: none; -}