-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TINY-11763: fix jumping cursor on delete within list #10184
base: main
Are you sure you want to change the base?
Conversation
WalkthroughThis update addresses issues related to cursor behavior and error handling when empty blocks within list items are deleted. It ensures that the cursor moves to the end of the Changes
Suggested labels
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (2)
⏰ Context from checks skipped due to timeout of 90000ms (1)
🔇 Additional comments (3)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
modules/tinymce/src/plugins/lists/main/ts/core/Delete.ts (1)
191-194
: Consider enhancing error handling.While the check for
commonAncestorParent
prevents invalid operations, consider adding explicit error handling for edge cases.- if (!commonAncestorParent || dom.isChildOf(otherLi, commonAncestorParent)) { + if (!commonAncestorParent) { + editor.notificationManager.open({ + text: 'Invalid list structure detected.', + type: 'error' + }); + return false; + } + if (dom.isChildOf(otherLi, commonAncestorParent)) { return false; }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
.changes/unreleased/tinymce-TINY-11763-2025-02-19.yaml
(1 hunks)modules/tinymce/src/plugins/lists/main/ts/core/Delete.ts
(3 hunks)modules/tinymce/src/plugins/lists/test/ts/browser/BackspaceDeleteFromBlockIntoLiTest.ts
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (9)
- GitHub Check: task-list-completed
- GitHub Check: task-list-completed
- GitHub Check: task-list-completed
- GitHub Check: task-list-completed
- GitHub Check: task-list-completed
- GitHub Check: task-list-completed
- GitHub Check: task-list-completed
- GitHub Check: Analyze (javascript)
- GitHub Check: task-list-completed
🔇 Additional comments (5)
modules/tinymce/src/plugins/lists/test/ts/browser/BackspaceDeleteFromBlockIntoLiTest.ts (3)
148-171
: Well-structured test case!The test thoroughly validates the backspace behavior when deleting an empty div within a list item, including proper cursor positioning.
173-196
: Good test coverage for delete key behavior!The test effectively mirrors the backspace test case, ensuring consistent behavior for both deletion directions.
198-224
: Excellent edge case coverage!The test effectively validates backspace behavior with nested lists, ensuring proper merging of adjacent ordered lists.
modules/tinymce/src/plugins/lists/main/ts/core/Delete.ts (1)
236-238
: Improved variable naming and selection logic!The changes enhance code clarity with better variable naming and fix cursor positioning by using
nextCaretContainer
.Also applies to: 239-239, 253-253
.changes/unreleased/tinymce-TINY-11763-2025-02-19.yaml (1)
1-8
: Clear and well-structured changelog entry!The entry effectively communicates the fixed issues and follows the proper YAML format.
a7b89e7
to
c3f765a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
modules/tinymce/src/plugins/lists/test/ts/browser/BackspaceDeleteFromBlockIntoLiTest.ts (2)
173-196
: Consider reducing test setup duplication.While the test case is well-structured and validates the delete operation correctly, it shares identical initial content with the previous test. Consider extracting the common setup into a helper function to improve maintainability.
Example refactor:
const setupEmptyDivTest = (editor: Editor) => { editor.setContent('<ul>' + '<li>' + '<div>' + '<strong>One</strong>' + '<div><br></div>' + '</div>' + '<div><strong>Two</strong></div>' + '</li>' + '</ul>'); TinySelections.setCursor(editor, [ 0, 0, 0, 1 ], 0); };
198-224
: Add cursor position assertion.The test case thoroughly validates the content structure after backspace operation, but it's missing an assertion for the final cursor position. Adding this assertion would ensure the cursor behaves correctly when merging the lists.
Add cursor position assertion after the content assertion:
TinyAssertions.assertCursor(editor, [ 0, 0, 0, 1, 1 ], 0);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
.changes/unreleased/tinymce-TINY-11763-2025-02-19.yaml
(1 hunks)modules/tinymce/src/plugins/lists/main/ts/core/Delete.ts
(3 hunks)modules/tinymce/src/plugins/lists/test/ts/browser/BackspaceDeleteFromBlockIntoLiTest.ts
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- .changes/unreleased/tinymce-TINY-11763-2025-02-19.yaml
- modules/tinymce/src/plugins/lists/main/ts/core/Delete.ts
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Analyze (javascript)
🔇 Additional comments (1)
modules/tinymce/src/plugins/lists/test/ts/browser/BackspaceDeleteFromBlockIntoLiTest.ts (1)
148-171
: Well-structured test case!The test case thoroughly validates the backspace operation from an empty div within a list item, ensuring both content structure and cursor positioning are correct after the operation.
c3f765a
to
0321723
Compare
@@ -0,0 +1,7 @@ | |||
project: tinymce | |||
kind: Fixed | |||
body: Deleting an empty block within <li> would move cursor at the end of the <li>. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is one long message. I wonder if you could split it up into two log items with the same issue ID since its fixing two bugs.
Related Ticket: TINY-11763
Description of Changes:
<li>
would move cursor at the end of the<li>
.<li>
.Pre-checks:
feature/
,hotfix/
orspike/
Review:
GitHub issues (if applicable):
Summary by CodeRabbit
<div>
elements in list items.