From 3374affa35052f0cd16c5148f4d8cfeedeb533ff Mon Sep 17 00:00:00 2001 From: jahorton Date: Wed, 22 Jan 2020 10:59:40 +0700 Subject: [PATCH] fix(web): blur->focus handles horiz scrolling --- web/source/dom/input.ts | 29 +++-------------------------- 1 file changed, 3 insertions(+), 26 deletions(-) diff --git a/web/source/dom/input.ts b/web/source/dom/input.ts index 8045d086e6..ece93d6ea0 100644 --- a/web/source/dom/input.ts +++ b/web/source/dom/input.ts @@ -79,32 +79,9 @@ namespace com.keyman.dom { this.processedSelectionStart = start; this.processedSelectionEnd = end; - this.doScroll(); - } - - doScroll() { - let dummyKey = 32; - - // Non-IE browsers: create the event this way. keyCode's bugged on InputEvent in Chrome, - // so we bypass that with a base Event instead. - if(typeof Event == 'function') { - event = new Event('keypress'); - event['key'] = " "; - event['code'] = 0x20; - event['keyCode'] = 0x20; - event['location'] = 0; - event['getModifierState'] = function() { - return 0; - } - } else { // Yeah, so IE can't use the above at all, and requires its own trick. - event = document.createEvent('KeyboardEvent'); - // An override to ensure that IE's method gets called. - // Many thanks to https://gist.github.com/termi/4654819, line 142 at the time of writing this. - var success = (event).initKeyboardEvent('keypress', false, true, null, dummyKey, 0, - '', 0, 0); - } - - this.root.dispatchEvent(event); + //Forces scrolling; the re-focus triggers the scroll, at least. + this.root.blur(); + this.root.focus(); } getTextBeforeCaret(): string {