Skip to content

Commit 3a35ebb

Browse files
authored
TreeView: support selection by shift+arrows/home/end when showCheckBoxesMode='none' (#31279)
1 parent 04d7f0b commit 3a35ebb

2 files changed

Lines changed: 776 additions & 701 deletions

File tree

packages/devextreme/js/__internal/ui/tree_view/tree_view.base.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1971,7 +1971,7 @@ class TreeViewBase extends HierarchicalCollectionWidget<TreeViewBaseProperties,
19711971
}
19721972

19731973
_moveFocus(location: string, e: DxEvent<KeyboardEvent>): void {
1974-
const { rtlEnabled } = this.option();
1974+
const { rtlEnabled, selectByClick } = this.option();
19751975

19761976
const FOCUS_UP = 'up';
19771977
const FOCUS_DOWN = 'down';
@@ -1993,14 +1993,16 @@ class TreeViewBase extends HierarchicalCollectionWidget<TreeViewBaseProperties,
19931993
return;
19941994
}
19951995

1996+
const isSelectionByShiftAllowed = this._showCheckboxes() || selectByClick;
1997+
19961998
switch (location) {
19971999
case FOCUS_UP: {
19982000
const $prevItem = this._prevItem($items);
19992001
this.option('focusedElement', getPublicElement($prevItem));
20002002

20012003
const prevItemElement = this._getNodeItemElement($prevItem);
20022004
this.getScrollable().scrollToElement(prevItemElement);
2003-
if (e.shiftKey && this._showCheckboxes()) {
2005+
if (e.shiftKey && isSelectionByShiftAllowed) {
20042006
this._updateItemSelection(true, prevItemElement);
20052007
}
20062008
break;
@@ -2011,14 +2013,14 @@ class TreeViewBase extends HierarchicalCollectionWidget<TreeViewBaseProperties,
20112013

20122014
const nextItemElement = this._getNodeItemElement($nextItem);
20132015
this.getScrollable().scrollToElement(nextItemElement);
2014-
if (e.shiftKey && this._showCheckboxes()) {
2016+
if (e.shiftKey && isSelectionByShiftAllowed) {
20152017
this._updateItemSelection(true, nextItemElement);
20162018
}
20172019
break;
20182020
}
20192021
case FOCUS_FIRST: {
20202022
const $firstItem = $items.first();
2021-
if (e.shiftKey && this._showCheckboxes()) {
2023+
if (e.shiftKey && isSelectionByShiftAllowed) {
20222024
this._updateSelectionToFirstItem($items, $items.index(this._prevItem($items)));
20232025
}
20242026

@@ -2029,7 +2031,7 @@ class TreeViewBase extends HierarchicalCollectionWidget<TreeViewBaseProperties,
20292031
case FOCUS_LAST: {
20302032
const $lastItem = $items.last();
20312033

2032-
if (e.shiftKey && this._showCheckboxes()) {
2034+
if (e.shiftKey && isSelectionByShiftAllowed) {
20332035
this._updateSelectionToLastItem($items, $items.index(this._nextItem($items)));
20342036
}
20352037

0 commit comments

Comments
 (0)