Skip to content

Commit 1eef433

Browse files
committed
wip
1 parent 40ee8d2 commit 1eef433

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

selection-grid-flow/src/main/java/com/vaadin/componentfactory/selectiongrid/SelectionTreeGrid.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public SelectionTreeGrid(HierarchicalDataProvider<T, ?> dataProvider) {
8585
}
8686

8787
/**
88-
* Runs the super.onAttach and hides the multi selection column afterwards (if necessary). * necessary).
88+
* Runs the super.onAttach and hides the multi selection column afterwards (if necessary).
8989
*
9090
* @param attachEvent event
9191
*/
@@ -162,7 +162,7 @@ private void selectionTreeGridSelectRange(String endItemKey, ObjectNode options)
162162
throw new IllegalArgumentException("Item with key %s not found".formatted(endItemKey));
163163
}
164164

165-
var range = fetchItemRange(rangeStartItem, rangeEndItem);
165+
var range = fetchRange(rangeStartItem, rangeEndItem);
166166

167167
var deselectOthers = options.get("deselectOthers").asBoolean(false);
168168
if (deselectOthers) {
@@ -172,7 +172,7 @@ private void selectionTreeGridSelectRange(String endItemKey, ObjectNode options)
172172
}
173173
}
174174

175-
private List<T> fetchItemRange(T startItem, T endItem) {
175+
private List<T> fetchRange(T startItem, T endItem) {
176176
var items = fetchHierarchyRecursively(null);
177177
var startIndex = items.indexOf(startItem);
178178
var endIndex = items.indexOf(endItem);
@@ -194,7 +194,7 @@ protected void setSelectionModel(GridSelectionModel<T> model, SelectionMode sele
194194
* is not removed, but set to "hidden" explicitly.
195195
*/
196196
protected void hideMultiSelectionColumn() {
197-
this.setMultiSelectionColumnVisible(false);
197+
this.setMultiSelectionColumnVisible(false);
198198
}
199199

200200
@Override
@@ -270,7 +270,6 @@ public void setMultiSelectionColumnVisible(boolean multiSelectionColumnVisible)
270270

271271
/**
272272
* Returns true if the checkbox selection is persistent, false otherwise.
273-
*
274273
* @return
275274
*/
276275
public boolean isPersistentCheckboxSelection() {
@@ -279,7 +278,6 @@ public boolean isPersistentCheckboxSelection() {
279278

280279
/**
281280
* Sets the checkbox selection to be persistent or not.
282-
*
283281
* @param persistentCheckboxSelection - true to make the checkbox selection persistent, false otherwise
284282
*/
285283
public void setPersistentCheckboxSelection(boolean persistentCheckboxSelection) {

selection-grid-flow/src/main/resources/META-INF/resources/frontend/src/helpers.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,17 @@ export function _selectionGridSelectRowWithItem(e, item, index) {
7070
}
7171
// if ctrl click
7272
if (e.shiftKey && this.rangeSelectRowFrom >= 0) {
73+
if((this.rangeSelectRowFrom - index) !== 0) { // clear text selection, if multiple rows are selected using shift
74+
const sel = window.getSelection ? window.getSelection() : document.selection;
75+
if (sel) {
76+
if (sel.removeAllRanges) {
77+
sel.removeAllRanges();
78+
} else if (sel.empty) {
79+
sel.empty();
80+
}
81+
}
82+
}
83+
7384
if (!ctrlKey) {
7485
if (this.$server?.selectionTreeGridSelectRange) {
7586
this.$server.selectionTreeGridSelectRange(item.key, { deselectOthers: true });

0 commit comments

Comments
 (0)