From c8e3efe0f20ed33d6e904501a7bd9ba80c818aa6 Mon Sep 17 00:00:00 2001
From: Javier Godoy <11554739+javier-godoy@users.noreply.github.com>
Date: Wed, 8 Apr 2026 12:17:42 -0300
Subject: [PATCH 1/3] revert: fix: register VaadinServiceInitListener to bundle
grid styles
This reverts commit 9ade7eaa0cd38cf03e740f971f78b862a132462e.
---
.../GridHelperServiceInitListener.java | 46 -------------------
...adin.flow.server.VaadinServiceInitListener | 1 -
2 files changed, 47 deletions(-)
delete mode 100644 src/main/java/com/flowingcode/vaadin/addons/gridhelpers/GridHelperServiceInitListener.java
delete mode 100644 src/main/resources/META-INF/services/com.vaadin.flow.server.VaadinServiceInitListener
diff --git a/src/main/java/com/flowingcode/vaadin/addons/gridhelpers/GridHelperServiceInitListener.java b/src/main/java/com/flowingcode/vaadin/addons/gridhelpers/GridHelperServiceInitListener.java
deleted file mode 100644
index 25f3be4..0000000
--- a/src/main/java/com/flowingcode/vaadin/addons/gridhelpers/GridHelperServiceInitListener.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*-
- * #%L
- * Grid Helpers Add-on
- * %%
- * Copyright (C) 2022 - 2026 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%
- */
-
-package com.flowingcode.vaadin.addons.gridhelpers;
-
-import com.vaadin.flow.component.dependency.CssImport;
-import com.vaadin.flow.server.ServiceInitEvent;
-import com.vaadin.flow.server.VaadinServiceInitListener;
-
-/**
- * Ensures that the addon's grid styles are always included in the production bundle.
- *
- *
{@code VaadinServiceInitListener} subtypes are discovered via ClassGraph reflection and are
- * always treated as entry points, regardless of how consumers use the addon. Placing the
- * {@code @CssImport} annotation here guarantees that the grid styles are included even when
- * {@link GridHelper} is not reachable through bytecode analysis.
- *
- * @see Issue #171
- */
-@CssImport(value = GridHelper.GRID_STYLES, themeFor = "vaadin-grid")
-public class GridHelperServiceInitListener implements VaadinServiceInitListener {
-
- @Override
- public void serviceInit(ServiceInitEvent event) {
- // No initialization needed; this class exists solely to anchor the
- // @CssImport annotation so it is always picked up during the production
- // bundle build via ClassGraph entry-point seeding.
- }
-}
diff --git a/src/main/resources/META-INF/services/com.vaadin.flow.server.VaadinServiceInitListener b/src/main/resources/META-INF/services/com.vaadin.flow.server.VaadinServiceInitListener
deleted file mode 100644
index e483373..0000000
--- a/src/main/resources/META-INF/services/com.vaadin.flow.server.VaadinServiceInitListener
+++ /dev/null
@@ -1 +0,0 @@
-com.flowingcode.vaadin.addons.gridhelpers.GridHelperServiceInitListener
From 4922c8b857d0d68b1f32ca11b71f1109e7ea7e13 Mon Sep 17 00:00:00 2001
From: Timo Meinen
Date: Fri, 27 Mar 2026 09:59:00 +0100
Subject: [PATCH 2/3] fix: ensure dense theme CSS is included in production
bundle
Add setDenseTheme(Grid, boolean) and isDenseTheme(Grid) methods that
create a bytecode reference to GridHelper, ensuring the Vaadin production
bundle scanner discovers its @CssImport annotations.
The DENSE_THEME constant is a compile-time constant (static final String),
so javac inlines it at the call site. When a consumer only uses the
constant (e.g. grid.addThemeName(GridHelper.DENSE_THEME)), no bytecode
reference to GridHelper is emitted and the scanner never reaches it.
DENSE_THEME is deprecated in favor of the new methods.
Closes #171
Co-authored-by: Javier Godoy <11554739+javier-godoy@users.noreply.github.com>
---
README.md | 2 +-
.../vaadin/addons/gridhelpers/GridHelper.java | 40 ++++++++++++++++++-
.../addons/gridhelpers/AllFeaturesDemo.java | 8 +---
.../addons/gridhelpers/DenseThemeDemo.java | 2 +-
4 files changed, 43 insertions(+), 9 deletions(-)
diff --git a/README.md b/README.md
index 4f146d3..0b19136 100644
--- a/README.md
+++ b/README.md
@@ -84,7 +84,7 @@ The class `GridHelper` provides several static methods that receive a `Grid` or
```
grid.setSelectionMode(SelectionMode.MULTI);
-grid.addThemeName(GridHelper.DENSE_THEME);
+GridHelper.setDenseTheme(grid, true);
GridHelper.setSelectOnClick(grid, true);
GridHelper.setArrowSelectionEnabled(grid, true);
GridHelper.setSelectionColumnHidden(grid, true);
diff --git a/src/main/java/com/flowingcode/vaadin/addons/gridhelpers/GridHelper.java b/src/main/java/com/flowingcode/vaadin/addons/gridhelpers/GridHelper.java
index 9a668d1..8ab6408 100644
--- a/src/main/java/com/flowingcode/vaadin/addons/gridhelpers/GridHelper.java
+++ b/src/main/java/com/flowingcode/vaadin/addons/gridhelpers/GridHelper.java
@@ -78,7 +78,45 @@ public final class GridHelper implements Serializable {
/** Compact row styling for Vaadin Grid */
// https://cookbook.vaadin.com/grid-dense-theme
- public static final String DENSE_THEME = "fcGh-dense";
+ private static final String DENSE_THEME_NAME = "fcGh-dense";
+
+ /**
+ * Compact row styling for Vaadin Grid.
+ *
+ * @deprecated Use {@link #setDenseTheme(Grid, boolean)} instead. Direct use of this constant
+ * bypasses the bytecode reference to {@code GridHelper}, which prevents the Vaadin production
+ * bundle scanner from discovering the required {@code @CssImport} annotations.
+ */
+ @Deprecated(since = "2.1.0", forRemoval = true)
+ public static final String DENSE_THEME = DENSE_THEME_NAME;
+
+ /**
+ * Adds or removes compact row styling on the given grid.
+ *
+ * Prefer this method over {@code grid.addThemeName(GridHelper.DENSE_THEME)} because it
+ * creates a bytecode reference to {@code GridHelper}, ensuring that the Vaadin production
+ * bundle scanner discovers the required {@code @CssImport} annotations.
+ *
+ * @param grid the grid to style
+ * @param dense {@code true} to enable dense theme, {@code false} to remove it
+ */
+ public static void setDenseTheme(Grid> grid, boolean dense) {
+ if (dense) {
+ grid.addThemeName(DENSE_THEME_NAME);
+ } else {
+ grid.removeThemeName(DENSE_THEME_NAME);
+ }
+ }
+
+ /**
+ * Returns whether the dense theme is currently applied to the given grid.
+ *
+ * @param grid the grid to check
+ * @return {@code true} if the dense theme is applied
+ */
+ public static boolean isDenseTheme(Grid> grid) {
+ return grid.hasThemeName(DENSE_THEME_NAME);
+ }
@Getter(value = AccessLevel.PACKAGE)
private final Grid grid;
diff --git a/src/test/java/com/flowingcode/vaadin/addons/gridhelpers/AllFeaturesDemo.java b/src/test/java/com/flowingcode/vaadin/addons/gridhelpers/AllFeaturesDemo.java
index 3a2f6a1..fad5d65 100644
--- a/src/test/java/com/flowingcode/vaadin/addons/gridhelpers/AllFeaturesDemo.java
+++ b/src/test/java/com/flowingcode/vaadin/addons/gridhelpers/AllFeaturesDemo.java
@@ -263,15 +263,11 @@ private boolean hasSelectionFilter(Grid grid) {
}
private void setDenseTheme(Grid grid, boolean value) {
- if (value) {
- grid.addThemeName(GridHelper.DENSE_THEME);
- } else {
- grid.removeThemeName(GridHelper.DENSE_THEME);
- }
+ GridHelper.setDenseTheme(grid, value);
}
private boolean hasDenseTheme(Grid grid) {
- return grid.hasThemeName(GridHelper.DENSE_THEME);
+ return GridHelper.isDenseTheme(grid);
}
private void setHeaderHidden(Grid grid, boolean value) {
diff --git a/src/test/java/com/flowingcode/vaadin/addons/gridhelpers/DenseThemeDemo.java b/src/test/java/com/flowingcode/vaadin/addons/gridhelpers/DenseThemeDemo.java
index 7b0b72a..995a215 100644
--- a/src/test/java/com/flowingcode/vaadin/addons/gridhelpers/DenseThemeDemo.java
+++ b/src/test/java/com/flowingcode/vaadin/addons/gridhelpers/DenseThemeDemo.java
@@ -44,7 +44,7 @@ public DenseThemeDemo() {
grid.addColumn(Person::getLastName).setHeader("Last name");
grid.addColumn(Person::getCountry).setHeader("Country");
- grid.addThemeName(GridHelper.DENSE_THEME);
+ GridHelper.setDenseTheme(grid, true);
grid.setHeightFull();
add(grid);
From eccbdf061ada1b80c121f4c8e4fd891f1495f99d Mon Sep 17 00:00:00 2001
From: Javier Godoy <11554739+javier-godoy@users.noreply.github.com>
Date: Wed, 8 Apr 2026 12:49:19 -0300
Subject: [PATCH 3/3] build: set version to 2.1.0-SNAPSHOT
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index 445e382..591b87b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
org.vaadin.addons.flowingcode
grid-helpers
- 2.0.1-SNAPSHOT
+ 2.1.0-SNAPSHOT
Grid Helpers Add-on
Grid Helpers Add-on for Vaadin Flow
https://www.flowingcode.com/en/open-source/