Skip to content

Commit

Permalink
Attach editor to DOM earlier
Browse files Browse the repository at this point in the history
FIX: Make sure that, when an editor creates tooltips immediately on initialization,
the editor is attached to the document when their `mount` callback is called.

See https://discuss.codemirror.net/t/the-mount-callback-in-tooltipview-is-invoked-before-it-is-attached-to-the-dom/7560
  • Loading branch information
marijnh committed Dec 13, 2023
1 parent 9b9fd27 commit f29c2ec
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/editorview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ export class EditorView {
this.dom.appendChild(this.announceDOM)
this.dom.appendChild(this.scrollDOM)

if (config.parent) config.parent.appendChild(this.dom)

let {dispatch} = config
this.dispatchTransactions = config.dispatchTransactions ||
(dispatch && ((trs: readonly Transaction[]) => trs.forEach(tr => dispatch!(tr, this)))) ||
Expand All @@ -212,8 +214,6 @@ export class EditorView {
this.updateState = UpdateState.Idle

this.requestMeasure()

if (config.parent) config.parent.appendChild(this.dom)
}

/// All regular editor state updates should go through this. It
Expand Down

0 comments on commit f29c2ec

Please sign in to comment.