From bd0274415b9413adf002b2bca70dfb83a3d7d995 Mon Sep 17 00:00:00 2001 From: Francisco Hodge Date: Thu, 7 Mar 2019 20:51:57 -0500 Subject: [PATCH] Fixed onChangeAll callback --- src/lib/components/Keyboard.js | 6 ++++++ src/lib/components/tests/Keyboard.test.js | 16 ++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/lib/components/Keyboard.js b/src/lib/components/Keyboard.js index 1ba0ab69..c2a14791 100644 --- a/src/lib/components/Keyboard.js +++ b/src/lib/components/Keyboard.js @@ -208,6 +208,12 @@ class SimpleKeyboard { */ if (typeof this.options.onChange === "function") this.options.onChange(this.input[this.options.inputName]); + + /** + * Calling onChangeAll + */ + if (typeof this.options.onChangeAll === "function") + this.options.onChangeAll(this.input); } if (debug) { diff --git a/src/lib/components/tests/Keyboard.test.js b/src/lib/components/tests/Keyboard.test.js index 2fe56223..d2d33bfa 100644 --- a/src/lib/components/tests/Keyboard.test.js +++ b/src/lib/components/tests/Keyboard.test.js @@ -186,6 +186,22 @@ it('Keyboard onChange will work', () => { expect(output).toBe("q"); }); +it('Keyboard onChangeAll will work', () => { + testUtil.setDOM(); + + let output; + + let keyboard = new Keyboard({ + onChangeAll: (input) => { + output = input ? input.default : null; + } + }); + + keyboard.getButtonElement("q").onclick(); + + expect(output).toBe("q"); +}); + it('Keyboard clearInput will work', () => { testUtil.setDOM();