-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Bug: Cannot escape lists with Enter key #4893
Comments
@pistachiomatt try to import import { LexicalComposer } from "@lexical/react/LexicalComposer";
import { RichTextPlugin } from "@lexical/react/LexicalRichTextPlugin";
import { ContentEditable } from "@lexical/react/LexicalContentEditable";
import LexicalErrorBoundary from "@lexical/react/LexicalErrorBoundary";
import editorConfig from "./editorConfig";
// New component
import { ListPlugin } from '@lexical/react/LexicalListPlugin';
export default function Editor() {
return (
<LexicalComposer initialConfig={editorConfig}>
<div className="editor-container">
<RichTextPlugin
contentEditable={<ContentEditable className="editor-input" />}
placeholder={<Placeholder />}
ErrorBoundary={LexicalErrorBoundary}
/>
{/* New Component */}
<ListPlugin />
</div>
</LexicalComposer>
);
}
function Placeholder() {
return <div className="editor-placeholder">Enter some plain text...</div>;
} |
Thanks! It works. A bit strange that a plugin is required to fix a bug. Perhaps this ticket should be to merge the plugin into core. |
If lists are in your editor, you already have it imported, so I highly doubt that's the reason for it, especially since I'm also seeing this. I had the same issue, but only rarely, and there is no difference between the extracted jsons between a list that works correctly with the enter key, and one that creates infinite lists and can't be escaped. Honestly unsure what could be causing it, but it does seem very strange overall, and I can't even provide a repro with a codebase, because I can't pin down the exact reason it is happening. I literally copy-pasted the content of one editor where the bug appeared into another and it no longer showed up. |
I have this issue as well, im using Vanilla js, i cannot exit the list with double enter keypress |
I also encountered this bug. It seems that the issue was caused by inadvertently adding libraries that are already defined by default within 'lexical', such as 'yarn add @lexical/code @lexical/markdown'. Once I removed all lexical libraries other than 'lexical' and '@lexical/react', everything started working smoothly. |
I am experiencing this too. I followed what @Atsuyoshi-Funahashi mentioned, removing all other lexical libraries, which may have had an impact as I'm sure I've seen it working on my implementation. But, I cannot seem to get it to work at all now. I'm sure I did have it working before. I'll continue to dig and I will feedback if I can work out what the cause is. |
Ok, interestingly when I render my component separately in Storybook I don't get this issue occurring. However I do when it's embedded in my application. In storybook I am just using my import { Control, Controller } from "react-hook-form";
import { Item } from "../../../external";
import WYSIWYGEditor from "../../wysiwyg";
export interface WYSIWYGEditorProps {
item: Item;
isSaving: boolean;
viewOnly: boolean;
control: Control<Item>;
}
const ItemDescription = ({
isSaving,
viewOnly,
control,
item,
}: WYSIWYGEditorProps): JSX.Element => {
return (
<>
<Controller
name="description"
control={control}
render={({
field: { onChange, value, name },
}) => {
return (
<WYSIWYGEditor
isSaving={isSaving}
setValue={onChange}
value={value}
viewOnly={viewOnly}
namespace={`${item.itemId}${name}`}
/>
);
}}
></Controller>
</>
);
};
export default ItemDescription; |
Edit I Still having this problem on my app today. |
Lexical version: 0.12
Steps To Reproduce
Expected: Pressing enter in an empty list reduces the list by 1 level (or exits it when it's the first level)
Demo: https://codesandbox.io/s/lexical-plain-text-example-forked-9lq9y8
(This bug was previously reported and closed, but it appears to have reoccured: #4266)
The text was updated successfully, but these errors were encountered: