From ae2d66436f451e6556896624d979b00a288144fd Mon Sep 17 00:00:00 2001 From: Ethan Alvizo Date: Mon, 16 Oct 2023 19:59:41 -0400 Subject: [PATCH 1/7] wip --- packages/grid/src/Grid.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/grid/src/Grid.tsx b/packages/grid/src/Grid.tsx index d5dc36b3d3..61d1fdf2f9 100644 --- a/packages/grid/src/Grid.tsx +++ b/packages/grid/src/Grid.tsx @@ -1323,6 +1323,12 @@ class Grid extends PureComponent { * @param viewState New state properties to set. * @param forceUpdate Whether to force an update. */ + // add in new param to take in event type + // user scroll in drag bar + // mouse wheel event down + // keyboard arrow event down + // keyboard shortcut like end, page down + // otherwise don't change setViewState(viewState: Partial, forceUpdate = false): void { if (!this.metrics) throw new Error('metrics not set'); From 762b61e7444628a7d63a4d3832e126b4c5427bf1 Mon Sep 17 00:00:00 2001 From: Ethan Alvizo Date: Mon, 16 Oct 2023 23:35:00 -0400 Subject: [PATCH 2/7] wip --- packages/grid/src/Grid.tsx | 32 +++++++++++++------ .../src/key-handlers/SelectionKeyHandler.ts | 9 ++++-- 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/packages/grid/src/Grid.tsx b/packages/grid/src/Grid.tsx index 61d1fdf2f9..0e5d8c72cc 100644 --- a/packages/grid/src/Grid.tsx +++ b/packages/grid/src/Grid.tsx @@ -1323,20 +1323,34 @@ class Grid extends PureComponent { * @param viewState New state properties to set. * @param forceUpdate Whether to force an update. */ - // add in new param to take in event type - // user scroll in drag bar - // mouse wheel event down - // keyboard arrow event down - // keyboard shortcut like end, page down - // otherwise don't change - setViewState(viewState: Partial, forceUpdate = false): void { + + setViewState( + viewState: Partial, + forceUpdate = false, + eventType: WheelEvent | GridKeyboardEvent | null = null + ): void { if (!this.metrics) throw new Error('metrics not set'); const { isStickyBottom, isStickyRight } = this.props; const { top, left } = viewState; const { lastTop, lastLeft } = this.metrics; + let isUserInputDown = false; + + if (eventType instanceof WheelEvent) { + isUserInputDown = eventType.deltaY > 0; + } else if ( + eventType instanceof KeyboardEvent || + (eventType && 'nativeEvent' in eventType) // used to catch the case that a synthetic react keyboard event is passed + ) { + isUserInputDown = + eventType.key === 'ArrowDown' || + eventType.key === 'End' || + eventType.key === 'PageDown'; + } if (top != null) { - this.setState({ isStuckToBottom: isStickyBottom && top >= lastTop }); + this.setState({ + isStuckToBottom: isStickyBottom && top >= lastTop && isUserInputDown, + }); } if (left != null) { this.setState({ isStuckToRight: isStickyRight && left >= lastLeft }); @@ -1984,7 +1998,7 @@ class Grid extends PureComponent { } } - this.setViewState({ top, left, leftOffset, topOffset }); + this.setViewState({ top, left, leftOffset, topOffset }, false, event); event.stopPropagation(); event.preventDefault(); diff --git a/packages/grid/src/key-handlers/SelectionKeyHandler.ts b/packages/grid/src/key-handlers/SelectionKeyHandler.ts index 20ae726f13..935c29d304 100644 --- a/packages/grid/src/key-handlers/SelectionKeyHandler.ts +++ b/packages/grid/src/key-handlers/SelectionKeyHandler.ts @@ -185,7 +185,7 @@ class SelectionKeyHandler extends KeyHandler { grid.moveCursorToPosition(left, cursorRow, isShiftKey, false); - grid.setViewState({ left }); + grid.setViewState({ left }, false, event); } else if (autoSelectColumn && deltaRow !== 0) { const { lastTop } = grid.metrics; let { top } = grid.state; @@ -194,9 +194,12 @@ class SelectionKeyHandler extends KeyHandler { grid.moveCursorToPosition(top, cursorColumn, isShiftKey, false); - grid.setViewState({ top }); + grid.setViewState({ top }, false, event); } else { + const { lastLeft, lastTop } = grid.metrics; + grid.moveCursor(deltaColumn, deltaRow, isShiftKey); + grid.setViewState({ left: lastLeft, top: lastTop }, false, event); // need to call setViewState again since moveCursor calls a series of functions that sets view state } } return true; @@ -279,7 +282,7 @@ class SelectionKeyHandler extends KeyHandler { isShiftKey, false ); - grid.setViewState({ top: viewportPosition }); + grid.setViewState({ top: viewportPosition }, false, e); return true; } From 5fd344b5fc0edbc058db0cfe9398aee96308df13 Mon Sep 17 00:00:00 2001 From: Ethan Alvizo Date: Tue, 17 Oct 2023 21:58:12 -0400 Subject: [PATCH 3/7] fix: stuck to bottom on filter clear --- packages/grid/src/Grid.tsx | 47 ++++++++++++------- .../src/key-handlers/SelectionKeyHandler.ts | 5 +- 2 files changed, 32 insertions(+), 20 deletions(-) diff --git a/packages/grid/src/Grid.tsx b/packages/grid/src/Grid.tsx index 0e5d8c72cc..970a9a44dd 100644 --- a/packages/grid/src/Grid.tsx +++ b/packages/grid/src/Grid.tsx @@ -1181,11 +1181,13 @@ class Grid extends PureComponent { * @param deltaColumn Number of columns to move the cursor * @param deltaRow Number of rows to move the cursor * @param extendSelection True if the current selection should be extended, false to start a new selection + * @param event The event that triggered the update. */ moveCursor( deltaColumn: number, deltaRow: number, - extendSelection: boolean + extendSelection: boolean, + event?: GridKeyboardEvent ): void { const { cursorRow, cursorColumn, selectionEndColumn, selectionEndRow } = this.state; @@ -1193,14 +1195,14 @@ class Grid extends PureComponent { const row = extendSelection ? selectionEndRow : cursorRow; if (row === null || column === null) { const { left, top } = this.state; - this.moveCursorToPosition(left, top, extendSelection); + this.moveCursorToPosition(left, top, extendSelection, true, false, event); } else { const { model } = this.props; const { columnCount, rowCount } = model; const left = clamp(column + deltaColumn, 0, columnCount - 1); const top = clamp(row + deltaRow, 0, rowCount - 1); - this.moveCursorToPosition(left, top, extendSelection); + this.moveCursorToPosition(left, top, extendSelection, true, false, event); } } @@ -1260,13 +1262,15 @@ class Grid extends PureComponent { * @param extendSelection Whether to extend the current selection (eg. holding Shift) * @param keepCursorInView Whether to move the viewport so that the cursor is in view * @param maximizePreviousRange With this and `extendSelection` true, it will maximize/add to the previous range only, ignoring where the selection was started + * @param event The event that triggered the update. */ moveCursorToPosition( column: GridRangeIndex, row: GridRangeIndex, extendSelection = false, keepCursorInView = true, - maximizePreviousRange = false + maximizePreviousRange = false, + event?: GridKeyboardEvent ): void { if (!extendSelection) { this.beginSelection(column, row); @@ -1275,7 +1279,7 @@ class Grid extends PureComponent { this.moveSelection(column, row, extendSelection, maximizePreviousRange); if (keepCursorInView) { - this.moveViewToCell(column, row); + this.moveViewToCell(column, row, event); } } @@ -1284,8 +1288,13 @@ class Grid extends PureComponent { * * @param column The column index to bring into view * @param row The row index to bring into view + * @param event The event that triggered the update. */ - moveViewToCell(column: GridRangeIndex, row: GridRangeIndex): void { + moveViewToCell( + column: GridRangeIndex, + row: GridRangeIndex, + event?: GridKeyboardEvent + ): void { if (!this.metrics) throw new Error('metrics not set'); const { metricCalculator } = this; @@ -1314,7 +1323,7 @@ class Grid extends PureComponent { } } - this.setViewState({ top, left, topOffset, leftOffset }); + this.setViewState({ top, left, topOffset, leftOffset }, false, event); } /** @@ -1322,12 +1331,13 @@ class Grid extends PureComponent { * Should be called when user interaction occurs * @param viewState New state properties to set. * @param forceUpdate Whether to force an update. + * @param event The event that triggered the update. */ setViewState( viewState: Partial, forceUpdate = false, - eventType: WheelEvent | GridKeyboardEvent | null = null + event?: WheelEvent | GridKeyboardEvent ): void { if (!this.metrics) throw new Error('metrics not set'); @@ -1335,17 +1345,20 @@ class Grid extends PureComponent { const { top, left } = viewState; const { lastTop, lastLeft } = this.metrics; let isUserInputDown = false; + let isUserInputRight = false; - if (eventType instanceof WheelEvent) { - isUserInputDown = eventType.deltaY > 0; + if (event instanceof WheelEvent) { + isUserInputDown = event.deltaY > 0; + isUserInputRight = event.deltaX > 0; } else if ( - eventType instanceof KeyboardEvent || - (eventType && 'nativeEvent' in eventType) // used to catch the case that a synthetic react keyboard event is passed + event instanceof KeyboardEvent || + (event && 'nativeEvent' in event) // used to catch the case that a synthetic react keyboard event is passed ) { isUserInputDown = - eventType.key === 'ArrowDown' || - eventType.key === 'End' || - eventType.key === 'PageDown'; + event.key === 'ArrowDown' || + event.key === 'End' || + event.key === 'PageDown'; + isUserInputRight = event.key === 'ArrowRight'; } if (top != null) { this.setState({ @@ -1353,7 +1366,9 @@ class Grid extends PureComponent { }); } if (left != null) { - this.setState({ isStuckToRight: isStickyRight && left >= lastLeft }); + this.setState({ + isStuckToRight: isStickyRight && left >= lastLeft && isUserInputRight, + }); } this.setState(viewState as GridState); diff --git a/packages/grid/src/key-handlers/SelectionKeyHandler.ts b/packages/grid/src/key-handlers/SelectionKeyHandler.ts index 935c29d304..68a2fb70f7 100644 --- a/packages/grid/src/key-handlers/SelectionKeyHandler.ts +++ b/packages/grid/src/key-handlers/SelectionKeyHandler.ts @@ -196,10 +196,7 @@ class SelectionKeyHandler extends KeyHandler { grid.setViewState({ top }, false, event); } else { - const { lastLeft, lastTop } = grid.metrics; - - grid.moveCursor(deltaColumn, deltaRow, isShiftKey); - grid.setViewState({ left: lastLeft, top: lastTop }, false, event); // need to call setViewState again since moveCursor calls a series of functions that sets view state + grid.moveCursor(deltaColumn, deltaRow, isShiftKey, event); } } return true; From 9f224ef41887b8c119d0eab22b2cb2a18d7035a7 Mon Sep 17 00:00:00 2001 From: Ethan Alvizo Date: Fri, 20 Oct 2023 01:19:41 -0400 Subject: [PATCH 4/7] PR feedback --- packages/grid/src/Grid.tsx | 84 +++++++++++++------ .../src/key-handlers/SelectionKeyHandler.ts | 29 +++++-- 2 files changed, 79 insertions(+), 34 deletions(-) diff --git a/packages/grid/src/Grid.tsx b/packages/grid/src/Grid.tsx index 970a9a44dd..9c9f8e9bcf 100644 --- a/packages/grid/src/Grid.tsx +++ b/packages/grid/src/Grid.tsx @@ -68,6 +68,11 @@ type LegacyCanvasRenderingContext2D = CanvasRenderingContext2D & { backingStorePixelRatio?: number; }; +export type StickyOptions = { + shouldStickBottom?: boolean; + shouldStickRight?: boolean; +}; + export type GridProps = typeof Grid.defaultProps & { // Options to set on the canvas canvasOptions?: CanvasRenderingContext2DSettings; @@ -1187,7 +1192,7 @@ class Grid extends PureComponent { deltaColumn: number, deltaRow: number, extendSelection: boolean, - event?: GridKeyboardEvent + stickyOptions?: StickyOptions ): void { const { cursorRow, cursorColumn, selectionEndColumn, selectionEndRow } = this.state; @@ -1195,14 +1200,28 @@ class Grid extends PureComponent { const row = extendSelection ? selectionEndRow : cursorRow; if (row === null || column === null) { const { left, top } = this.state; - this.moveCursorToPosition(left, top, extendSelection, true, false, event); + this.moveCursorToPosition( + left, + top, + extendSelection, + true, + false, + stickyOptions + ); } else { const { model } = this.props; const { columnCount, rowCount } = model; const left = clamp(column + deltaColumn, 0, columnCount - 1); const top = clamp(row + deltaRow, 0, rowCount - 1); - this.moveCursorToPosition(left, top, extendSelection, true, false, event); + this.moveCursorToPosition( + left, + top, + extendSelection, + true, + false, + stickyOptions + ); } } @@ -1270,7 +1289,7 @@ class Grid extends PureComponent { extendSelection = false, keepCursorInView = true, maximizePreviousRange = false, - event?: GridKeyboardEvent + stickyOptions?: StickyOptions ): void { if (!extendSelection) { this.beginSelection(column, row); @@ -1279,7 +1298,7 @@ class Grid extends PureComponent { this.moveSelection(column, row, extendSelection, maximizePreviousRange); if (keepCursorInView) { - this.moveViewToCell(column, row, event); + this.moveViewToCell(column, row, stickyOptions); } } @@ -1293,7 +1312,7 @@ class Grid extends PureComponent { moveViewToCell( column: GridRangeIndex, row: GridRangeIndex, - event?: GridKeyboardEvent + stickyOptions?: StickyOptions ): void { if (!this.metrics) throw new Error('metrics not set'); @@ -1323,7 +1342,19 @@ class Grid extends PureComponent { } } - this.setViewState({ top, left, topOffset, leftOffset }, false, event); + // const stickyOptions: StickyOptions = { + // shouldStickBottom: + // event && + // (event.key === 'ArrowDown' || + // event.key === 'End' || + // event.key === 'PageDown'), + // shouldStickRight: event && event.key === 'ArrowRight', + // }; + this.setViewState( + { top, left, topOffset, leftOffset }, + false, + stickyOptions + ); } /** @@ -1337,37 +1368,28 @@ class Grid extends PureComponent { setViewState( viewState: Partial, forceUpdate = false, - event?: WheelEvent | GridKeyboardEvent + stickyOptions?: StickyOptions ): void { if (!this.metrics) throw new Error('metrics not set'); const { isStickyBottom, isStickyRight } = this.props; const { top, left } = viewState; const { lastTop, lastLeft } = this.metrics; - let isUserInputDown = false; - let isUserInputRight = false; - - if (event instanceof WheelEvent) { - isUserInputDown = event.deltaY > 0; - isUserInputRight = event.deltaX > 0; - } else if ( - event instanceof KeyboardEvent || - (event && 'nativeEvent' in event) // used to catch the case that a synthetic react keyboard event is passed - ) { - isUserInputDown = - event.key === 'ArrowDown' || - event.key === 'End' || - event.key === 'PageDown'; - isUserInputRight = event.key === 'ArrowRight'; - } + if (top != null) { this.setState({ - isStuckToBottom: isStickyBottom && top >= lastTop && isUserInputDown, + isStuckToBottom: + isStickyBottom && + top >= lastTop && + (stickyOptions?.shouldStickBottom ?? false), }); } if (left != null) { this.setState({ - isStuckToRight: isStickyRight && left >= lastLeft && isUserInputRight, + isStuckToRight: + isStickyRight && + left >= lastLeft && + (stickyOptions?.shouldStickRight ?? false), }); } @@ -2013,7 +2035,15 @@ class Grid extends PureComponent { } } - this.setViewState({ top, left, leftOffset, topOffset }, false, event); + const stickyOptions: StickyOptions = { + shouldStickBottom: event.deltaY > 0, + shouldStickRight: event.deltaX > 0, + }; + this.setViewState( + { top, left, leftOffset, topOffset }, + false, + stickyOptions + ); event.stopPropagation(); event.preventDefault(); diff --git a/packages/grid/src/key-handlers/SelectionKeyHandler.ts b/packages/grid/src/key-handlers/SelectionKeyHandler.ts index 68a2fb70f7..a4e8bad628 100644 --- a/packages/grid/src/key-handlers/SelectionKeyHandler.ts +++ b/packages/grid/src/key-handlers/SelectionKeyHandler.ts @@ -1,7 +1,7 @@ /* eslint class-methods-use-this: "off" */ import clamp from 'lodash.clamp'; import { EventHandlerResult } from '../EventHandlerResult'; -import Grid from '../Grid'; +import Grid, { StickyOptions } from '../Grid'; import GridRange from '../GridRange'; import GridUtils from '../GridUtils'; import KeyHandler, { GridKeyboardEvent } from '../KeyHandler'; @@ -177,6 +177,13 @@ class SelectionKeyHandler extends KeyHandler { const { theme } = grid.props; const { autoSelectRow = false, autoSelectColumn = false } = theme; + const stickyOptions: StickyOptions = { + shouldStickBottom: + event.key === 'ArrowDown' || + event.key === 'End' || + event.key === 'PageDown', + shouldStickRight: event.key === 'ArrowRight', + }; if (autoSelectRow && deltaColumn !== 0) { const { lastLeft } = grid.metrics; let { left } = grid.state; @@ -185,7 +192,7 @@ class SelectionKeyHandler extends KeyHandler { grid.moveCursorToPosition(left, cursorRow, isShiftKey, false); - grid.setViewState({ left }, false, event); + grid.setViewState({ left }, false, stickyOptions); } else if (autoSelectColumn && deltaRow !== 0) { const { lastTop } = grid.metrics; let { top } = grid.state; @@ -194,9 +201,9 @@ class SelectionKeyHandler extends KeyHandler { grid.moveCursorToPosition(top, cursorColumn, isShiftKey, false); - grid.setViewState({ top }, false, event); + grid.setViewState({ top }, false, stickyOptions); } else { - grid.moveCursor(deltaColumn, deltaRow, isShiftKey, event); + grid.moveCursor(deltaColumn, deltaRow, isShiftKey, stickyOptions); } } return true; @@ -242,8 +249,8 @@ class SelectionKeyHandler extends KeyHandler { return true; } - handlePageDown(e: GridKeyboardEvent, grid: Grid): boolean { - const isShiftKey = e.shiftKey; + handlePageDown(event: GridKeyboardEvent, grid: Grid): boolean { + const isShiftKey = event.shiftKey; if (isShiftKey) { grid.trimSelectedRanges(); @@ -279,7 +286,15 @@ class SelectionKeyHandler extends KeyHandler { isShiftKey, false ); - grid.setViewState({ top: viewportPosition }, false, e); + + const stickyOptions: StickyOptions = { + shouldStickBottom: + event.key === 'ArrowDown' || + event.key === 'End' || + event.key === 'PageDown', + shouldStickRight: event.key === 'ArrowRight', + }; + grid.setViewState({ top: viewportPosition }, false, stickyOptions); return true; } From 6c2b0170ca7442a6f773b10eec33a48fb8a1158b Mon Sep 17 00:00:00 2001 From: Ethan Alvizo Date: Fri, 20 Oct 2023 01:23:14 -0400 Subject: [PATCH 5/7] update JSDocs --- packages/grid/src/Grid.tsx | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/packages/grid/src/Grid.tsx b/packages/grid/src/Grid.tsx index 9c9f8e9bcf..60ca94d5ee 100644 --- a/packages/grid/src/Grid.tsx +++ b/packages/grid/src/Grid.tsx @@ -1186,7 +1186,7 @@ class Grid extends PureComponent { * @param deltaColumn Number of columns to move the cursor * @param deltaRow Number of rows to move the cursor * @param extendSelection True if the current selection should be extended, false to start a new selection - * @param event The event that triggered the update. + * @param stickyOptions Options for sticky behavior */ moveCursor( deltaColumn: number, @@ -1281,7 +1281,7 @@ class Grid extends PureComponent { * @param extendSelection Whether to extend the current selection (eg. holding Shift) * @param keepCursorInView Whether to move the viewport so that the cursor is in view * @param maximizePreviousRange With this and `extendSelection` true, it will maximize/add to the previous range only, ignoring where the selection was started - * @param event The event that triggered the update. + * @param stickyOptions Options for sticky behavior */ moveCursorToPosition( column: GridRangeIndex, @@ -1307,7 +1307,7 @@ class Grid extends PureComponent { * * @param column The column index to bring into view * @param row The row index to bring into view - * @param event The event that triggered the update. + * @param stickyOptions Options for sticky behavior */ moveViewToCell( column: GridRangeIndex, @@ -1342,14 +1342,6 @@ class Grid extends PureComponent { } } - // const stickyOptions: StickyOptions = { - // shouldStickBottom: - // event && - // (event.key === 'ArrowDown' || - // event.key === 'End' || - // event.key === 'PageDown'), - // shouldStickRight: event && event.key === 'ArrowRight', - // }; this.setViewState( { top, left, topOffset, leftOffset }, false, @@ -1362,7 +1354,7 @@ class Grid extends PureComponent { * Should be called when user interaction occurs * @param viewState New state properties to set. * @param forceUpdate Whether to force an update. - * @param event The event that triggered the update. + * @param stickyOptions Options for sticky behavior */ setViewState( From 9799e9f2031adf341a6b10cd236b498d9c312ce9 Mon Sep 17 00:00:00 2001 From: Ethan Alvizo Date: Tue, 24 Oct 2023 19:55:17 -0400 Subject: [PATCH 6/7] removed key check --- packages/grid/src/Grid.tsx | 14 +++------ .../src/key-handlers/SelectionKeyHandler.ts | 29 ++++++++++--------- 2 files changed, 20 insertions(+), 23 deletions(-) diff --git a/packages/grid/src/Grid.tsx b/packages/grid/src/Grid.tsx index 60ca94d5ee..9fb4eab2e7 100644 --- a/packages/grid/src/Grid.tsx +++ b/packages/grid/src/Grid.tsx @@ -1368,20 +1368,14 @@ class Grid extends PureComponent { const { top, left } = viewState; const { lastTop, lastLeft } = this.metrics; - if (top != null) { + if (top != null && (stickyOptions?.shouldStickBottom ?? false)) { this.setState({ - isStuckToBottom: - isStickyBottom && - top >= lastTop && - (stickyOptions?.shouldStickBottom ?? false), + isStuckToBottom: isStickyBottom && top >= lastTop, }); } - if (left != null) { + if (left != null && (stickyOptions?.shouldStickRight ?? false)) { this.setState({ - isStuckToRight: - isStickyRight && - left >= lastLeft && - (stickyOptions?.shouldStickRight ?? false), + isStuckToRight: isStickyRight && left >= lastLeft, }); } diff --git a/packages/grid/src/key-handlers/SelectionKeyHandler.ts b/packages/grid/src/key-handlers/SelectionKeyHandler.ts index a4e8bad628..1aaa8605f4 100644 --- a/packages/grid/src/key-handlers/SelectionKeyHandler.ts +++ b/packages/grid/src/key-handlers/SelectionKeyHandler.ts @@ -144,6 +144,11 @@ class SelectionKeyHandler extends KeyHandler { grid.state; const column = isShiftKey ? selectionEndColumn : cursorColumn; const row = isShiftKey ? selectionEndRow : cursorRow; + const stickyOptions: StickyOptions = { + shouldStickBottom: deltaRow > 0, + shouldStickRight: deltaColumn > 0, + }; + if (isModifierKey) { const { model } = grid.props; const { columnCount, rowCount } = model; @@ -169,7 +174,8 @@ class SelectionKeyHandler extends KeyHandler { moveToRow, isShiftKey, true, - maximizePreviousRange + maximizePreviousRange, + stickyOptions ); } } else { @@ -177,13 +183,13 @@ class SelectionKeyHandler extends KeyHandler { const { theme } = grid.props; const { autoSelectRow = false, autoSelectColumn = false } = theme; - const stickyOptions: StickyOptions = { - shouldStickBottom: - event.key === 'ArrowDown' || - event.key === 'End' || - event.key === 'PageDown', - shouldStickRight: event.key === 'ArrowRight', - }; + // const stickyOptions: StickyOptions = { + // shouldStickBottom: + // event.key === 'ArrowDown' || + // event.key === 'End' || + // event.key === 'PageDown', + // shouldStickRight: event.key === 'ArrowRight', + // }; if (autoSelectRow && deltaColumn !== 0) { const { lastLeft } = grid.metrics; let { left } = grid.state; @@ -288,11 +294,8 @@ class SelectionKeyHandler extends KeyHandler { ); const stickyOptions: StickyOptions = { - shouldStickBottom: - event.key === 'ArrowDown' || - event.key === 'End' || - event.key === 'PageDown', - shouldStickRight: event.key === 'ArrowRight', + shouldStickBottom: true, + shouldStickRight: false, }; grid.setViewState({ top: viewportPosition }, false, stickyOptions); From e42f72bf47ed06545c6e0f54c8857d41596cc2fb Mon Sep 17 00:00:00 2001 From: Ethan Alvizo Date: Fri, 27 Oct 2023 01:38:45 -0400 Subject: [PATCH 7/7] remove commented code --- packages/grid/src/key-handlers/SelectionKeyHandler.ts | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/packages/grid/src/key-handlers/SelectionKeyHandler.ts b/packages/grid/src/key-handlers/SelectionKeyHandler.ts index 1aaa8605f4..e1144fa619 100644 --- a/packages/grid/src/key-handlers/SelectionKeyHandler.ts +++ b/packages/grid/src/key-handlers/SelectionKeyHandler.ts @@ -183,13 +183,7 @@ class SelectionKeyHandler extends KeyHandler { const { theme } = grid.props; const { autoSelectRow = false, autoSelectColumn = false } = theme; - // const stickyOptions: StickyOptions = { - // shouldStickBottom: - // event.key === 'ArrowDown' || - // event.key === 'End' || - // event.key === 'PageDown', - // shouldStickRight: event.key === 'ArrowRight', - // }; + if (autoSelectRow && deltaColumn !== 0) { const { lastLeft } = grid.metrics; let { left } = grid.state;