Skip to content

Commit 6d21371

Browse files
committed
TreeView: support selection by shift+arrows/home/end when showCheckBoxesMode='none' (#31279)
1 parent 9d42435 commit 6d21371

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
@@ -1972,7 +1972,7 @@ class TreeViewBase extends HierarchicalCollectionWidget<TreeViewBaseProperties,
19721972
}
19731973

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

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

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

20022004
const prevItemElement = this._getNodeItemElement($prevItem);
20032005
this.getScrollable().scrollToElement(prevItemElement);
2004-
if (e.shiftKey && this._showCheckboxes()) {
2006+
if (e.shiftKey && isSelectionByShiftAllowed) {
20052007
this._updateItemSelection(true, prevItemElement);
20062008
}
20072009
break;
@@ -2012,14 +2014,14 @@ class TreeViewBase extends HierarchicalCollectionWidget<TreeViewBaseProperties,
20122014

20132015
const nextItemElement = this._getNodeItemElement($nextItem);
20142016
this.getScrollable().scrollToElement(nextItemElement);
2015-
if (e.shiftKey && this._showCheckboxes()) {
2017+
if (e.shiftKey && isSelectionByShiftAllowed) {
20162018
this._updateItemSelection(true, nextItemElement);
20172019
}
20182020
break;
20192021
}
20202022
case FOCUS_FIRST: {
20212023
const $firstItem = $items.first();
2022-
if (e.shiftKey && this._showCheckboxes()) {
2024+
if (e.shiftKey && isSelectionByShiftAllowed) {
20232025
this._updateSelectionToFirstItem($items, $items.index(this._prevItem($items)));
20242026
}
20252027

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

2033-
if (e.shiftKey && this._showCheckboxes()) {
2035+
if (e.shiftKey && isSelectionByShiftAllowed) {
20342036
this._updateSelectionToLastItem($items, $items.index(this._nextItem($items)));
20352037
}
20362038

0 commit comments

Comments
 (0)