diff --git a/web/source/osk/oskManager.ts b/web/source/osk/oskManager.ts index d0a2d98754..2e56761f18 100644 --- a/web/source/osk/oskManager.ts +++ b/web/source/osk/oskManager.ts @@ -197,8 +197,10 @@ namespace com.keyman.osk { s.fontSize = fontScale + 'em'; } + if(this.vkbd) { + this.vkbd.shutdown(); + } this.vkbd = null; - // TODO: Consider a 'vkbd.release()' method? // Instantly resets the OSK container, erasing / delinking the previously-loaded keyboard. this._Box.innerHTML = ''; @@ -311,6 +313,9 @@ namespace com.keyman.osk { * Description Generates the visual keyboard element and attaches it to KMW */ private _GenerateVisualKeyboard(keyboard: keyboards.Keyboard) { + if(this.vkbd) { + this.vkbd.shutdown(); + } this.vkbd = new com.keyman.osk.VisualKeyboard(keyboard); let util = com.keyman.singleton.util; diff --git a/web/source/osk/visualKeyboard.ts b/web/source/osk/visualKeyboard.ts index d32690d586..7e1e3fc14b 100644 --- a/web/source/osk/visualKeyboard.ts +++ b/web/source/osk/visualKeyboard.ts @@ -2763,5 +2763,14 @@ namespace com.keyman.osk { }, 5000); return false; }; + + shutdown() { + let keyman = com.keyman.singleton; + + // Prevents style-sheet pollution from multiple keyboard swaps. + if(this.styleSheet) { + keyman.util.removeStyleSheet(this.styleSheet); + } + } } }