Open zhanghan3 opened 1 year ago
But they all need to focus on editor
Why do you think this? I don't think this should be the case.
But they all need to focus on editor
Why do you think this? I don't think this should be the case.
Sorry for not clear. I mean if I use any of two way above, the cursor will be focused in the editor.
My question is: After page is initialized, can I set default value for the editor and focus the cursor on other input fields?
If you set selection while inserting nodes (either via rootNode.select()
or elsewhere), you can call $setSelection(null) in the end to reset selection and avoid auto-focusing
I think rootNode.clear()
is stealing focus too, which is unexpected.
There should exist a way to call functions like $patchStyleText
without focusing the editor. As an example of this problem, try changing text color on the playground by entering a hex value. The moment you enter the last hex character, the focus is stolen. Calling $setSelection(null)
is not an option since we need to preserve the selection for further color changes while the color picker is open.
If you set selection while inserting nodes (either via
rootNode.select()
or elsewhere), you can call $setSelection(null) in the end to reset selection and avoid auto-focusing
I think this can help not focus on Lexical but this may also result in not focusing on the input element I am expecting. Here are two: Lexical editor and common input with autofocus props. If I set selection and then reset, there might not be any element be focused I think.
There are two selections: lexical's selection, and the DOM's selection. When you manipulate lexical's selection nothing happens to the DOM's selection until reconciliation (after the batch of update calls).
I am trying setting default value for lexcial editor from html string. I know that I can achieve by this:
or
But they all need to focus on editor. And there is another element needed be focused.
Is there any another way that I can set default value without focusing on editor.