caretPosition reset when inputName is changed through setOptions

This commit is contained in:
Francisco Hodge 2019-04-18 10:13:02 -04:00
parent 451b64d31a
commit 20d24d97fd

View File

@ -363,14 +363,40 @@ class SimpleKeyboard {
/**
* Set new option or modify existing ones after initialization.
* @param {object} option The option to set
* @param {object} options The options to set
*/
setOptions(options){
options = options || {};
this.options = Object.assign(this.options, options);
/**
* Some option changes require adjustments before re-render
*/
this.onSetOptions(options);
/**
* Rendering
*/
setOptions = option => {
option = option || {};
this.options = Object.assign(this.options, option);
this.render();
};
/**
* Executing actions depending on changed options
* @param {object} options The options to set
*/
onSetOptions(options){
if(options.inputName){
/**
* inputName changed. This requires a caretPosition reset
*/
if (this.options.debug) {
console.log("inputName changed. caretPosition reset.");
}
this.caretPosition = null;
}
}
/**
* Remove all keyboard rows and reset keyboard values.
* Used interally between re-renders.