mirror of
https://github.com/hodgef/simple-keyboard.git
synced 2025-01-19 16:52:59 +08:00
Ensure caretPosition is unset on disableCaretPositioning
This commit is contained in:
parent
6c2236f762
commit
1f9efb0c66
@ -542,24 +542,29 @@ class SimpleKeyboard {
|
|||||||
|
|
||||||
this.dispatch(instance => {
|
this.dispatch(instance => {
|
||||||
if(instance.isMouseHold){
|
if(instance.isMouseHold){
|
||||||
instance.isMouseHold = false;
|
instance.isMouseHold = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(
|
if(
|
||||||
(targetTagName === "textarea" ||
|
(targetTagName === "textarea" ||
|
||||||
targetTagName === "input") &&
|
targetTagName === "input") &&
|
||||||
!instance.options.disableCaretPositioning
|
!instance.options.disableCaretPositioning
|
||||||
){
|
){
|
||||||
/**
|
/**
|
||||||
* Tracks current cursor position
|
* Tracks current cursor position
|
||||||
* As keys are pressed, text will be added/removed at that position within the input.
|
* As keys are pressed, text will be added/removed at that position within the input.
|
||||||
*/
|
*/
|
||||||
instance.caretPosition = event.target.selectionStart;
|
instance.caretPosition = event.target.selectionStart;
|
||||||
|
|
||||||
if(instance.options.debug){
|
if(instance.options.debug){
|
||||||
console.log("Caret at: ", event.target.selectionStart, event.target.tagName.toLowerCase(), `(${instance.keyboardDOMClass})`);
|
console.log("Caret at: ", event.target.selectionStart, event.target.tagName.toLowerCase(), `(${instance.keyboardDOMClass})`);
|
||||||
}
|
}
|
||||||
}
|
} else if(instance.options.disableCaretPositioning){
|
||||||
|
/**
|
||||||
|
* If we toggled off disableCaretPositioning, we must ensure caretPosition doesn't persist once reactivated.
|
||||||
|
*/
|
||||||
|
instance.caretPosition = null;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user