Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adjusts table keyboard navigation so pressing ArrowUp preserves horizontal caret placement by computing the insertion point at the top edge of the target cell, preventing the cursor from getting “stuck” and enabling movement into the cell above.
Changes:
- Update ArrowUp caret hit-testing to use the target cell’s
rect.topinstead ofrect.top - 1. - Expand/add a unit test scenario for ArrowUp to validate horizontal-position preservation when the browser initially lands in the wrong column.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/roosterjs-content-model-core/lib/corePlugin/selection/SelectionPlugin.ts | Tweaks the Y coordinate passed to getNodePositionFromEvent for ArrowUp within table navigation. |
| packages/roosterjs-content-model-core/test/corePlugin/selection/SelectionPluginTest.ts | Updates/expands ArrowUp test coverage around preserving horizontal caret placement in tables. |
Comments suppressed due to low confidence (1)
packages/roosterjs-content-model-core/test/corePlugin/selection/SelectionPluginTest.ts:2216
- This new test mocks getNodePositionFromEvent but never asserts the coordinates it is called with. Since the production change is specifically about the Y coordinate used for ArrowUp (rect.top vs rect.top - 1), the test should include an expectation that getNodePositionFromEvent is invoked with the target cell's top Y value (and the original cursorRect.left) so the fix is actually covered and protected from regression.
// Mock getNodePositionFromEvent to return a specific position in td6 (middle row, third column)
const targetNode = testTd6_text;
const targetOffset = 1;
spyOn(getNodePositionFromEventFile, 'getNodePositionFromEvent').and.returnValue({
node: targetNode,
offset: targetOffset,
});
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
packages/roosterjs-content-model-core/test/corePlugin/selection/SelectionPluginTest.ts
Show resolved
Hide resolved
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When pressing arrow up, move the cursor to the top of the cell, so the cursor can be placed at the cell above.

Before:
After:
