kazupon / vue-validator

:white_check_mark: Validator component for Vue.js
MIT License
2.19k stars 431 forks source link

Error on blur when removing component #312

Open demianh opened 7 years ago

demianh commented 7 years ago

vue & vue-validator version

vue 1.0.26 vue-validator 2.1.7

Reproduction Link

https://jsfiddle.net/demianh/Lkd4mot2/1/

Steps to reproduce

Open the fiddle, and press enter while the focus is on the input field of the modal.

What is Expected?

The dialog closes without an error.

What is actually happening?

The dialog closes with an error: vue.js:3199 Uncaught TypeError: Cannot read property '$forContext' of null

demianh commented 7 years ago

I found a workaround for this problem. I need to call

document.activeElement.blur();

before the <validator> element is hidden. This fires the blur event before the DOM elements are removed.

EDIT: fiddle with the workaround: https://jsfiddle.net/demianh/zv238v6w/2/