UnigramDev/Unigram/develop • 1208597 • 2 files, +57/-1
Focus the editor when its window opens
The caret only ever appeared after re-activating the editor window. Two reasons,
both of them ordering:
TryFocus focused the document before the control. The JS view.focus() sets
document.activeElement inside a browser whose host has no focus — ProseMirror
even draws its selection — but the keyboard stays with XAML. Focusing the
control is what routes input into the web content; the document call only
places the caret, so it has to come second.
And ViewService.OpenAsync activates the window as soon as its content exists,
which is long before CoreWebView2 does. XAML's initial focus lands on the
WebView2 while it has no controller to forward it to, so that GotFocus goes
nowhere — and focusing it later is a no-op, because the control already has it.
Re-activating the window worked precisely because it raised GotFocus again.
Focus is now taken on activation (deferred, since XAML assigns its own while
activating) and, when the control is the one already holding it, moved off and
back so the transition actually happens.
Also drops the WebView2's Source: Initialize navigates to the same file through
the editor.unigram virtual host, so setting both loaded the whole editor twice
— two parses of the bundle and two ProseMirror mounts per open.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
UnigramDev/Unigram/develop • 2302a74 • 1 files, +2/-2
Hook SizeChanged to the right container
UnigramDev/Unigram/develop • 5e572a3 • 2 files, +9/-7
Fix purchase button
UnigramDev/Unigram/develop • 34ecd82 • 2 files, +8/-0
Fix default editor state
#unigram
Post #20631
46