diff --git a/src/lib/components/Keyboard.ts b/src/lib/components/Keyboard.ts index 2ea0bdd3..ab0c8475 100644 --- a/src/lib/components/Keyboard.ts +++ b/src/lib/components/Keyboard.ts @@ -887,6 +887,7 @@ class SimpleKeyboard { } this.keyboardDOM.className = this.keyboardDOMClass; + this.keyboardDOM.setAttribute("data-skInstance", this.currentInstanceName); this.buttonElements = {}; } @@ -1157,10 +1158,20 @@ class SimpleKeyboard { } this.dispatch((instance) => { - const isKeyboard = + let isKeyboard = event.target === instance.keyboardDOM || (event.target && instance.keyboardDOM.contains(event.target)); + /** + * If syncInstanceInputs option is enabled, make isKeyboard match any instance + * not just the current one + */ + if (this.options.syncInstanceInputs && Array.isArray(event.path)) { + isKeyboard = event.path.some((item: HTMLElement) => + item?.hasAttribute?.("data-skInstance") + ); + } + if ( (targetTagName === "textarea" || (targetTagName === "input" && @@ -1297,6 +1308,11 @@ class SimpleKeyboard { */ this.activeInputElement = null; + /** + * Removing instance attribute + */ + this.keyboardDOM.removeAttribute("data-skInstance"); + /** * Clearing keyboardDOM */ @@ -1677,6 +1693,11 @@ class SimpleKeyboard { useTouchEventsClass ); + /** + * Adding keyboard identifier + */ + this.keyboardDOM.setAttribute("data-skInstance", this.currentInstanceName); + /** * Create row wrapper */