Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Multiple input events on MdInput #1261
Edit: See this comment for what I believe fixes this issue.
Steps to reproduce
Use vue-dev-tools on the vue-material docs. (I can't seem to get the dev tools to activate on vuematerial.io, so I'm using a local copy a la
Watch the events and type in an input, textarea or change a select.
Latest Vue, git dev version of vue-material, latest stable Chrome
What is expected?
I would expect to only receive one input event. In the case of the select, I would expect to receive one event with the value of the selection.
What is actually happening?
You'll see two or three events for each key stroke. In case of the select, you'll get one input event with the value of the selection and another with the inner text of the selection.
In the case of MdInput, there's three sources that these events come from. First in
I don't know enough about how MdInput is supposed to work to fix it. I did notice that
Update: I'm realizing now, at least for the select problem, that one input event is coming from the MdSelect, and one is coming from the MdInput (built into the MdSelect?), which makes sense. But I still wouldn't think you'd want both events firing...
Edit: I'm dumb. Just because the the Vue dev tools shows the event doesn't mean it get's passed up to the parent. So the MdSelect is working just fine.
But the original issue with MdInput is still the same. The parent is seeing multiple input events.
Okay with the above in mind, I've isolated the events to two places. MdInput's $listeners (i.e.
I can't find a time when localValue doesn't emit on a change, so it seems like the input listener in MdInput is redundant. Perhaps it should become something like:
or something similar? If someone really wanted to get the native input event, they could just use
If this is acceptable, I can do a pull request to fix this issue with MdInput and MdTextarea.