Skip to content

fix(core): call scrollIntoView() on Enter#2802

Open
Wqrld wants to merge 1 commit into
TypeCellOS:mainfrom
Wqrld:fix/split-block-scroll-into-view
Open

fix(core): call scrollIntoView() on Enter#2802
Wqrld wants to merge 1 commit into
TypeCellOS:mainfrom
Wqrld:fix/split-block-scroll-into-view

Conversation

@Wqrld
Copy link
Copy Markdown

@Wqrld Wqrld commented May 30, 2026

Summary

Updates the enter handler to scrollintoview both globally and for listItems.

Part of #2801

Rationale

Without this handler, the cursor goes out of frame when pressing enter on the last line in the window

Changes

adds a scrollintoview call for the normal and listitem enter handler

Impact

None expected.

Testing

Tested in the playground environment. Does not overscroll the margins yet as in the demo video.

Screenshots/Video

See referenced issue

Checklist

  • Code follows the project's coding standards.
  • Unit tests covering the new feature have been added.
  • All existing tests pass.
  • The documentation has been updated to reflect the new feature

Additional Notes

There should be support for configuring the margin aswell (see original issue). I can try to add that here or in a separate PR

Summary by CodeRabbit

  • Bug Fixes
    • Improved scrolling behavior when pressing Enter to split blocks or list items, ensuring newly created content is automatically scrolled into view for better visibility.

Review Change Stack

updates the enter handler to scrollintoview both globally and for listItems.

Signed-off-by: Wqrld <wereld03@gmail.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 30, 2026

@Wqrld is attempting to deploy a commit to the TypeCell Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 30, 2026

📝 Walkthrough

Walkthrough

This PR adds automatic viewport scrolling to newly created blocks when splitting blocks with the Enter key. Both the list item handler and keyboard shortcut extension are updated to call .scrollIntoView() after the split operation, ensuring users see the newly created block without manual scrolling.

Changes

Scroll into view on block split

Layer / File(s) Summary
Scroll into view on block split
packages/core/src/blocks/utils/listItemEnterHandler.ts, packages/core/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts
List item Enter handler stores the split result, calls tr.scrollIntoView(), then returns it. Keyboard shortcut extension adds .scrollIntoView() to the command chain after split but before .run().

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Suggested reviewers

  • nperez0111
  • matthewlipski

Poem

🐰 A hop, a split, a block is born,
Now scroll reveals it, no need to mourn,
The cursor leaps where Enter goes,
Two pathways join—the viewport shows! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix(core): call scrollIntoView() on Enter' clearly and concisely summarizes the main change—adding a scrollIntoView call to the Enter key handler across multiple files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The PR description covers all major template sections with clear, relevant details aligned with the changes made.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Wqrld
Copy link
Copy Markdown
Author

Wqrld commented May 30, 2026

Would you be willing to promote editorprops to something that does not need accessing the internal _tiptapOptions so the margins and maybe other editorprops can be set nicely?

(Ref workaround diff in the original issue)

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.

1 participant