mirror of
https://github.com/webstudio-is/webstudio.git
synced 2026-12-01 21:05:42 +09:00
experimental: Pressing Enter within an empty list item deletes the empty item (#4641)
## Description ref #4595 ## Steps for reproduction 1. click button 2. expect xyz ## Code Review - [ ] hi @kof, I need you to do - conceptual review (architecture, feature-correctness) - detailed review (read every line) - test it on preview ## Before requesting a review - [ ] made a self-review - [ ] added inline comments where things may be not obvious (the "why", not "what") ## Before merging - [ ] tested locally and on preview environment (preview dev login: 0000) - [ ] updated [test cases](https://github.com/webstudio-is/webstudio/blob/main/apps/builder/docs/test-cases.md) document - [ ] added tests - [ ] if any new env variables are added, added them to `.env` file
This commit is contained in:
1 parent
21a97fb238
commit
640f9a4f2c
1 file changed
+15
-1
@@ -1127,7 +1127,11 @@ const RichTextContentPluginInternal = ({
|
||||
.get()
|
||||
.get(rootInstanceSelector[0]);
|
||||
|
||||
if (currentInstance?.component === "ListItem") {
|
||||
const rootNodeContent = $getRoot().getTextContent().trim();
|
||||
if (
|
||||
currentInstance?.component === "ListItem" &&
|
||||
rootNodeContent.length > 0
|
||||
) {
|
||||
// Instead of creating block component we need to add a new ListItem
|
||||
insertListItemAt(rootInstanceSelector);
|
||||
event.preventDefault();
|
||||
@@ -1183,6 +1187,16 @@ const RichTextContentPluginInternal = ({
|
||||
|
||||
insertTemplateAt(templateSelector, rootInstanceSelector, false);
|
||||
|
||||
if (
|
||||
currentInstance?.component === "ListItem" &&
|
||||
rootNodeContent.length === 0
|
||||
) {
|
||||
// Pressing Enter within an empty list item deletes the empty item
|
||||
updateWebstudioData((data) => {
|
||||
deleteInstanceMutable(data, rootInstanceSelector);
|
||||
});
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user