diff --git a/README.md b/README.md index c9bbb149..e5ca7828 100644 --- a/README.md +++ b/README.md @@ -77,9 +77,9 @@ Want to create your own module? Check out the [Modules page](https://hodgef.com/ > Simple-keyboard is intended for modern, standards-compliant browsers. > Internet Explorer is sadly not one of them, and since its market-share is negligible (~2% for IE11), resources won't be spent in trying to support it. > -> To learn more about the rationale for not supporting IE, check out [this link](https://techcommunity.microsoft.com/t5/Windows-IT-Pro-Blog/The-perils-of-using-Internet-Explorer-as-your-default-browser/ba-p/331732). +> For more information, check out [this Q&A entry](https://hodgef.com/simple-keyboard/questions-answers/internet-explorer-not-supported/). ## Contributing ✅ -PR's and issues are welcome. Feel free to submit any issues you have at: +PRs and issues are always welcome. Feel free to submit any issues you have at: [https://github.com/hodgef/simple-keyboard/issues](https://github.com/hodgef/simple-keyboard/issues) diff --git a/src/demo/index.js b/src/demo/index.js index 7b3f989f..144a2ee0 100644 --- a/src/demo/index.js +++ b/src/demo/index.js @@ -4,10 +4,10 @@ import "./css/index.css"; * Demos */ import BasicDemo from "./BasicDemo"; -// import ButtonThemeDemo from "./ButtonThemeDemo"; -// import DOMElementDemo from "./DOMElementDemo"; -// import FullKeyboardDemo from "./FullKeyboardDemo"; -// import MultipleKeyboardsDemo from "./MultipleKeyboardsDestroyDemo"; +//import ButtonThemeDemo from "./ButtonThemeDemo"; +//import DOMElementDemo from "./DOMElementDemo"; +//import FullKeyboardDemo from "./FullKeyboardDemo"; +//import MultipleKeyboardsDemo from "./MultipleKeyboardsDestroyDemo"; /** * Selected demo diff --git a/src/lib/components/Keyboard.js b/src/lib/components/Keyboard.js index d9f4a7de..1b09c009 100644 --- a/src/lib/components/Keyboard.js +++ b/src/lib/components/Keyboard.js @@ -27,7 +27,6 @@ class SimpleKeyboard { */ this.utilities = new Utilities({ getOptions: this.getOptions, - setCaretPosition: this.setCaretPosition, getCaretPosition: this.getCaretPosition, getCaretPositionEnd: this.getCaretPositionEnd, dispatch: this.dispatch @@ -231,10 +230,10 @@ class SimpleKeyboard { /** * Setters */ - setCaretPosition = (position, endPosition) => { + setCaretPosition(position, endPosition) { this.caretPosition = position; this.caretPositionEnd = endPosition || position; - }; + } /** * Handles clicks made to keyboard buttons @@ -544,10 +543,10 @@ class SimpleKeyboard { /** * inputName changed. This requires a caretPosition reset */ + // TODO: Review side-effects if (this.options.debug) { console.log("inputName changed. caretPosition reset."); } - this.setCaretPosition(null); } } @@ -873,6 +872,8 @@ class SimpleKeyboard { `(${instance.keyboardDOMClass})` ); } + + // TODO: Review side-effects } else if (!isKeyboard) { instance.setCaretPosition(null); } diff --git a/src/lib/services/Utilities.js b/src/lib/services/Utilities.js index 7d29a19c..982d94a6 100644 --- a/src/lib/services/Utilities.js +++ b/src/lib/services/Utilities.js @@ -5,17 +5,10 @@ class Utilities { /** * Creates an instance of the Utility service */ - constructor({ - getOptions, - setCaretPosition, - getCaretPosition, - getCaretPositionEnd, - dispatch - }) { + constructor({ getOptions, getCaretPosition, getCaretPositionEnd, dispatch }) { this.getOptions = getOptions; this.getCaretPosition = getCaretPosition; this.getCaretPositionEnd = getCaretPositionEnd; - this.setCaretPosition = setCaretPosition; this.dispatch = dispatch; /** @@ -203,15 +196,10 @@ class Utilities { */ updateCaretPos(length, minus) { const newCaretPos = this.updateCaretPosAction(length, minus); - const { syncInstanceInputs } = this.getOptions(); - if (syncInstanceInputs) { - this.dispatch(instance => { - instance.setCaretPosition(newCaretPos); - }); - } else { - this.setCaretPosition(newCaretPos); - } + this.dispatch(instance => { + instance.setCaretPosition(newCaretPos); + }); } /** @@ -285,8 +273,6 @@ class Utilities { positionEnd = source.length, moveCaret = false ) { - const { syncInstanceInputs } = this.getOptions(); - if (position === 0 && positionEnd === 0) { return source; } @@ -328,13 +314,9 @@ class Utilities { } else { output = source.slice(0, position) + source.slice(positionEnd); if (moveCaret) { - if (syncInstanceInputs) { - this.dispatch(instance => { - instance.setCaretPosition(position); - }); - } else { - this.setCaretPosition(position); - } + this.dispatch(instance => { + instance.setCaretPosition(position); + }); } } diff --git a/src/lib/services/tests/Utilities.test.js b/src/lib/services/tests/Utilities.test.js index ff55402d..d7ecff5c 100644 --- a/src/lib/services/tests/Utilities.test.js +++ b/src/lib/services/tests/Utilities.test.js @@ -490,11 +490,11 @@ it('Keyboard removeAt will propagate caretPosition', () => { keyboard.getButtonElement('{bksp}').onclick(); expect(keyboard.getCaretPosition()).toBe(1); - expect(keyboard2.getCaretPosition()).toBe(null); + expect(keyboard2.getCaretPosition()).toBe(1); expect(keyboard.getInput()).toBe('hlo'); expect(keyboard.getCaretPositionEnd()).toBe(1); - expect(keyboard2.getCaretPositionEnd()).toBe(null); + expect(keyboard2.getCaretPositionEnd()).toBe(1); }); it('Keyboard removeAt will propagate caretPosition in a syncInstanceInputs setting', () => {