Skip to content

Commit e1c416c

Browse files
authored
enhancement: don't auto scroll when sending cell to top/bottom from menu (#5544)
1 parent 989c586 commit e1c416c

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

frontend/src/components/editor/actions/useCellActionButton.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,13 +357,17 @@ export function useCellActionButtons({ cell }: Props) {
357357
icon: <ChevronsUpIcon size={13} strokeWidth={1.5} />,
358358
label: "Send to top",
359359
hotkey: "cell.sendToTop",
360-
handle: () => sendToTop({ cellId }),
360+
// When using the cell menu, likely the user doesn't want to scroll
361+
// and instead just wants to get the cell out of the way
362+
handle: () => sendToTop({ cellId, scroll: false }),
361363
},
362364
{
363365
icon: <ChevronsDownIcon size={13} strokeWidth={1.5} />,
364366
label: "Send to bottom",
365367
hotkey: "cell.sendToBottom",
366-
handle: () => sendToBottom({ cellId }),
368+
// When using the cell menu, likely the user doesn't want to scroll
369+
// and instead just wants to get the cell out of the way
370+
handle: () => sendToBottom({ cellId, scroll: false }),
367371
},
368372
{
369373
icon: <Columns2Icon size={13} strokeWidth={1.5} />,

frontend/src/core/cells/cells.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -450,13 +450,13 @@ const {
450450
scrollToBottom();
451451
return state;
452452
},
453-
sendToTop: (state, action: { cellId: CellId }) => {
453+
sendToTop: (state, action: { cellId: CellId; scroll?: boolean }) => {
454454
const column = state.cellIds.findWithId(action.cellId);
455455
if (column.length === 0) {
456456
return state;
457457
}
458458

459-
const { cellId } = action;
459+
const { cellId, scroll = true } = action;
460460
const cellIndex = column.indexOfOrThrow(cellId);
461461
if (cellIndex === 0) {
462462
return state;
@@ -465,16 +465,16 @@ const {
465465
return {
466466
...state,
467467
cellIds: state.cellIds.moveWithinColumn(column.id, cellIndex, 0),
468-
scrollKey: cellId,
468+
scrollKey: scroll ? cellId : null,
469469
};
470470
},
471-
sendToBottom: (state, action: { cellId: CellId }) => {
471+
sendToBottom: (state, action: { cellId: CellId; scroll?: boolean }) => {
472472
const column = state.cellIds.findWithId(action.cellId);
473473
if (column.length === 0) {
474474
return state;
475475
}
476476

477-
const { cellId } = action;
477+
const { cellId, scroll = true } = action;
478478
const cellIndex = column.indexOfOrThrow(cellId);
479479
const newIndex = column.length - 1;
480480

@@ -485,7 +485,7 @@ const {
485485
return {
486486
...state,
487487
cellIds: state.cellIds.moveWithinColumn(column.id, cellIndex, newIndex),
488-
scrollKey: cellId,
488+
scrollKey: scroll ? cellId : null,
489489
};
490490
},
491491
addColumn: (state, action: { columnId: CellColumnId }) => {

0 commit comments

Comments
 (0)