mirror of
https://github.com/vector-im/element-web.git
synced 2026-05-06 12:46:29 +02:00
fix(docs): place cursor after document content is loaded, not at WASM ready
This commit is contained in:
parent
93f2a2af3c
commit
d23a768a5f
@ -480,11 +480,6 @@ export const DocumentView = memo(function DocumentView({ room }: DocumentViewPro
|
||||
// LiveKit real-time transport (falls back gracefully if unavailable).
|
||||
const rtc = useDocumentRTC(room, client);
|
||||
|
||||
// Place the cursor at the end and focus the editor once the WASM model is
|
||||
// ready. Without this the editor is enabled but has no selection, so no
|
||||
// cursor appears even after the element receives focus.
|
||||
useSetCursorPosition(!isWysiwygReady, ref);
|
||||
|
||||
// Track whether the editor has content so we can hide the placeholder.
|
||||
const [hasContent, setHasContent] = useState(false);
|
||||
|
||||
@ -503,6 +498,13 @@ export const DocumentView = memo(function DocumentView({ room }: DocumentViewPro
|
||||
rtc,
|
||||
);
|
||||
|
||||
// Place the cursor at the end and focus the editor only after BOTH the WASM
|
||||
// model is ready AND the document content has been written to the DOM.
|
||||
// Waiting for isLoaded prevents the cursor being placed into the empty editor
|
||||
// before innerHTML is populated, which would leave it one position short on
|
||||
// the first keypress.
|
||||
useSetCursorPosition(!isWysiwygReady || !isLoaded, ref);
|
||||
|
||||
const handleInput = useCallback(() => {
|
||||
notifyContentChangedRef.current();
|
||||
scheduleDeltaSend();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user