Skip to content

Commit

Permalink
feat: pageUp/pageDown scrolling support (#1144)
Browse files Browse the repository at this point in the history
* feat: pageUp/pageDown scrolling support

* feat: pageUp/pageDown scrolling support
  • Loading branch information
kpodp0ra authored Dec 11, 2024
1 parent aeb01a7 commit a5898a5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/sdk/src/components/grid/InteractionLayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,7 @@ export const InteractionLayerBase: ForwardRefRenderFunction<
getCellContent={getCellContent}
real2RowIndex={real2RowIndex}
scrollToItem={scrollToItem}
scrollBy={scrollBy}
/>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export interface IEditorContainerProps
| 'onDelete'
| 'onRowAppend'
| 'onRowExpand'
| 'scrollBy'
> {
isEditing?: boolean;
scrollState: IScrollState;
Expand Down Expand Up @@ -97,6 +98,7 @@ export const EditorContainerBase: ForwardRefRenderFunction<
setSelection,
real2RowIndex,
getCellContent,
scrollBy,
} = props;
const { scrollLeft, scrollTop } = scrollState;
const { rowIndex, realRowIndex, columnIndex } = useMemo(() => {
Expand Down Expand Up @@ -148,6 +150,7 @@ export const EditorContainerBase: ForwardRefRenderFunction<
setActiveCell,
setSelection,
scrollToItem,
scrollBy,
});

const editorStyle = useMemo(
Expand Down
12 changes: 12 additions & 0 deletions packages/sdk/src/components/grid/hooks/useKeyboardSelection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const useKeyboardSelection = (props: ISelectionKeyboardProps) => {
onDelete,
onRowExpand,
editorRef,
scrollBy,
} = props;
const { pureRowCount, columnCount } = coordInstance;

Expand Down Expand Up @@ -143,6 +144,17 @@ export const useKeyboardSelection = (props: ISelectionKeyboardProps) => {
}
);

useHotkeys(
['PageUp', 'PageDown'],
() => {
const delta = coordInstance.containerHeight - coordInstance.rowInitSize - 1;
scrollBy(0, isHotkeyPressed('PageUp') ? -delta : delta);
},
{
enabled: Boolean(activeCell && !isEditing),
enableOnFormTags: ['input', 'select', 'textarea'],
}
);
useHotkeys(
'mod+a',
() => {
Expand Down

0 comments on commit a5898a5

Please sign in to comment.