Skip to content

Build your personal knowledge base with Trilium Notes

Close Virtual Keyboard when Mathinput is closed

Meinzzzz8a385972fc36
diff --git a/packages/ckeditor5-math/src/mathui.ts b/packages/ckeditor5-math/src/mathui.ts
index 5f36396d14..4bba3f304f 100644
--- a/packages/ckeditor5-math/src/mathui.ts
+++ b/packages/ckeditor5-math/src/mathui.ts
@@ -189,6 +189,9 @@ export default class MathUI extends Plugin {
private _removeFormView() {
if ( this._isFormInPanel && this.formView ) {
+ // Hide virtual keyboard before removing the form
+ this.formView.hideKeyboard();
+
this.formView.saveButtonView.focus();
this._balloon.remove( this.formView );
diff --git a/packages/ckeditor5-math/src/ui/mainformview.ts b/packages/ckeditor5-math/src/ui/mainformview.ts
index 5e9d069cf7..f8d8901cca 100644
--- a/packages/ckeditor5-math/src/ui/mainformview.ts
+++ b/packages/ckeditor5-math/src/ui/mainformview.ts
@@ -172,4 +172,8 @@ export default class MainFormView extends View {
} );
return btn;
}
+
+ public hideKeyboard(): void {
+ this.mathInputView.hideKeyboard();
+ }
}
diff --git a/packages/ckeditor5-math/src/ui/mathinputview.ts b/packages/ckeditor5-math/src/ui/mathinputview.ts
index 72c4e08fe1..c0e78b2748 100644
--- a/packages/ckeditor5-math/src/ui/mathinputview.ts
+++ b/packages/ckeditor5-math/src/ui/mathinputview.ts
@@ -36,13 +36,13 @@ export default class MathInputView extends View {
tag: 'div',
attributes: { class: ['ck-mathlive-container'] }
},
- // LaTeX label (outside wrapper)
+ // LaTeX label
{
tag: 'label',
attributes: { class: ['ck-latex-label'] },
children: [t('LaTeX')]
},
- // Raw LaTeX wrapper (just textarea now)
+ // Raw LaTeX wrapper
{
tag: 'div',
attributes: { class: ['ck-latex-wrapper'] },
@@ -176,15 +176,15 @@ export default class MathInputView extends View {
}
public hideKeyboard(): void {
- if (this.mathfield) {
- try {
- this.mathfield.blur();
- (this.mathfield as any).executeCommand?.('hideVirtualKeyboard');
- } catch { /* MathLive may already be disposed */ }
+ if (typeof window !== 'undefined' && window.mathVirtualKeyboard?.visible) {
+ window.mathVirtualKeyboard.hide();
}
}
public override destroy(): void {
+ // Hide keyboard before destroying
+ this.hideKeyboard();
+
if (this.mathfield) {
try {
this.mathfield.blur();