-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple input events on MdInput #1261
Comments
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. |
listeners () {
var l = this.$listeners
delete l.input
return l
} This way would modify the |
@VdustR Yeah, that was just example what I think |
try listeners () {
return {
...this.$listeners,
input: undefined
}
} |
Oh, that's much more elegant than I was thinking. I'm just waiting on some input from the devs before I do a pull request. |
@korylprince make PR and we can look at it. Its faster then waiting for response in issue. |
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
npm run dev
.)Watch the events and type in an input, textarea or change a select.
Which browser?
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.
Investigation
In the case of MdInput, there's three sources that these events come from. First in
listeners()
inMdInput.vue
.In
MdFieldMixin.js
theset(value)
for the computedmodel
, and the watcher forvalue
both setlocalValue
which causes an emit.I don't know enough about how MdInput is supposed to work to fix it. I did notice that
set(value)
formodel
checks ifvalue
is anInputEvent
. In all my testing the only thingvalue
ever is is aString
.The text was updated successfully, but these errors were encountered: