-
Notifications
You must be signed in to change notification settings - Fork 8
Description
Hello and thank you for this great component!
I'm currently using selection-grid-flow version 3.1.0 in a Vaadin 24.8.2 project and really like the way it extends the standard Grid functionality.
Unfortunately, I discovered a bug related to multi-selection with Shift+Click: the selection anchor does not reset after a regular click, leading to unexpected selection behavior.
Steps to Reproduce
Click on row 1 → [1] is selected
Click on row 5 (no modifier) → only [5] is selected
Shift + Click on row 7 → rows [1, 5, 6, 7] are selected ❌
Expected behavior
After clicking row 5, it should become the new selection anchor.
The Shift+Click on row 7 should then result in [5, 6, 7] only.
Minimal Reproducible Example
public class MySelectionGrid extends SelectionGrid<String> {
public MySelectionGrid() {
super();
this.addColumn(String::toString).setHeader("Random String Column");
this.setSelectionMode(SelectionMode.MULTI);
this.setItems(createRandomString(100));
// Uncomment the following block to fix the incorrect selection behavior:
// this.addItemClickListener(event -> {
// if (!event.isCtrlKey() && !event.isShiftKey() && !event.isMetaKey()) {
// this.deselectAll();
// this.select(event.getItem());
// }
// });
}
public static List<String> createRandomString(int count) {
List<String> randomStrings = new ArrayList<>();
for (int i = 0; i < count; i++) {
randomStrings.add(UUID.randomUUID().toString());
}
return randomStrings;
}
}
Workaround
If you uncomment the ItemClickListener block in the code above, the selection behavior becomes intuitive:
The selection is cleared on regular (non-modifier) clicks.
The clicked item becomes the new anchor for subsequent Shift+Click operations.
Thanks again for providing and maintaining this useful add-on!
Let me know if I can assist further in reproducing or testing the fix.
Best regards,
René