Skip to content

feat(toolbar): insert cells after focused cell#658

Merged
rgbkrk merged 1 commit intomainfrom
quill/add-cell-after-focused
Mar 9, 2026
Merged

feat(toolbar): insert cells after focused cell#658
rgbkrk merged 1 commit intomainfrom
quill/add-cell-after-focused

Conversation

@rgbkrk
Copy link
Member

@rgbkrk rgbkrk commented Mar 9, 2026

The toolbar's +Code and +Markdown buttons now insert new cells after the currently focused cell, instead of always prepending at the top. If no cell is focused, the new cell is inserted after the last cell (or at the top if the notebook is empty).

This matches the intuitive behavior of the inline "Add Cell" buttons that appear between cells.

Verification

  • Focus a cell and click +Code — new cell appears below focused cell
  • Focus a cell and click +Markdown — new cell appears below focused cell
  • Click outside cells to unfocus, then click +Code — new cell appears at bottom
  • Create a new notebook and click +Code — cell is added

PR submitted by @rgbkrk's agent, Quill

When clicking +Code or +Markdown in the toolbar, new cells now insert after the currently focused cell instead of at the top. If no cell is focused, the new cell is inserted after the last cell (or at the top if the notebook is empty).
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR modifies the notebook toolbar's +Code and +Markdown buttons to insert new cells contextually — after the currently focused cell — rather than always prepending at the top. When no cell is focused, cells are appended after the last existing cell (or at position 0 for empty notebooks). The addCell function in useAutomergeNotebook already accepted an optional afterCellId parameter, so the changes are limited to threading the focused cell ID and last cell ID to the toolbar component.

Changes:

  • Extended NotebookToolbarProps with focusedCellId and lastCellId props, and updated onAddCell signature to accept an optional afterCellId.
  • Updated toolbar button click handlers to pass focusedCellId ?? lastCellId as the insertion target.
  • Threaded the new props from AppContent to NotebookToolbar, computing lastCellId from the cells array.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
apps/notebook/src/components/NotebookToolbar.tsx Added focusedCellId and lastCellId props; updated +Code and +Markdown button handlers to pass the insertion position.
apps/notebook/src/App.tsx Passes focusedCellId and computed lastCellId to the NotebookToolbar component.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@rgbkrk rgbkrk enabled auto-merge (squash) March 9, 2026 19:38
@rgbkrk rgbkrk disabled auto-merge March 9, 2026 19:54
@rgbkrk rgbkrk merged commit 7f7a623 into main Mar 9, 2026
13 of 14 checks passed
@rgbkrk rgbkrk deleted the quill/add-cell-after-focused branch March 9, 2026 19:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants