From 6d2337fa4f6513ec774c6b09ec390fe0f47c79b2 Mon Sep 17 00:00:00 2001 From: John Ryan Camatog Date: Fri, 23 Jun 2017 22:51:13 +0800 Subject: [PATCH] Add blur and focus events to md-input --- docs/src/pages/components/Input.vue | 23 +++++++++++++++++++++++ src/components/mdInputContainer/common.js | 8 ++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/docs/src/pages/components/Input.vue b/docs/src/pages/components/Input.vue index f9554c6..62f30da 100644 --- a/docs/src/pages/components/Input.vue +++ b/docs/src/pages/components/Input.vue @@ -114,6 +114,29 @@ + + + + + Name + Value + Description + + + + + + focus + Emits the Event object + Triggered when the user focuses the input + + + blur + Emits the Event object + Triggered when the user loses focus of the input + + + diff --git a/src/components/mdInputContainer/common.js b/src/components/mdInputContainer/common.js index 0b35fad..9877ca3 100644 --- a/src/components/mdInputContainer/common.js +++ b/src/components/mdInputContainer/common.js @@ -68,14 +68,18 @@ export default { this.parentContainer.inputLength = newValue ? newValue.length : 0; }); }, - onFocus() { + onFocus(event) { if (this.parentContainer) { this.parentContainer.isFocused = true; } + + this.$emit('focus', event); }, - onBlur() { + onBlur(event) { this.parentContainer.isFocused = false; this.setParentValue(); + + this.$emit('blur', event); }, onInput() { this.updateValues();