mirror of
https://github.com/hodgef/simple-keyboard.git
synced 2025-04-27 00:00:19 +08:00
Ensure caret position is not lost when using syncInstanceInputs. Fixes https://github.com/hodgef/react-simple-keyboard/issues/1948
This commit is contained in:
parent
6dbf28364e
commit
a2d537bfe2
@ -887,6 +887,7 @@ class SimpleKeyboard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.keyboardDOM.className = this.keyboardDOMClass;
|
this.keyboardDOM.className = this.keyboardDOMClass;
|
||||||
|
this.keyboardDOM.setAttribute("data-skInstance", this.currentInstanceName);
|
||||||
this.buttonElements = {};
|
this.buttonElements = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1157,10 +1158,20 @@ class SimpleKeyboard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.dispatch((instance) => {
|
this.dispatch((instance) => {
|
||||||
const isKeyboard =
|
let isKeyboard =
|
||||||
event.target === instance.keyboardDOM ||
|
event.target === instance.keyboardDOM ||
|
||||||
(event.target && instance.keyboardDOM.contains(event.target));
|
(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 (
|
if (
|
||||||
(targetTagName === "textarea" ||
|
(targetTagName === "textarea" ||
|
||||||
(targetTagName === "input" &&
|
(targetTagName === "input" &&
|
||||||
@ -1297,6 +1308,11 @@ class SimpleKeyboard {
|
|||||||
*/
|
*/
|
||||||
this.activeInputElement = null;
|
this.activeInputElement = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removing instance attribute
|
||||||
|
*/
|
||||||
|
this.keyboardDOM.removeAttribute("data-skInstance");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clearing keyboardDOM
|
* Clearing keyboardDOM
|
||||||
*/
|
*/
|
||||||
@ -1677,6 +1693,11 @@ class SimpleKeyboard {
|
|||||||
useTouchEventsClass
|
useTouchEventsClass
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adding keyboard identifier
|
||||||
|
*/
|
||||||
|
this.keyboardDOM.setAttribute("data-skInstance", this.currentInstanceName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create row wrapper
|
* Create row wrapper
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user