Skip to content
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

Fixes #1218 - change triggered on blur #1251

Closed
wants to merge 3 commits into from
Closed

Fixes #1218 - change triggered on blur #1251

wants to merge 3 commits into from

Conversation

jacekkarczmarczyk
Copy link
Member

First commit removes emitting 'change' event on blur. Now the 'change' event is emitted only when input.value changes. However it emits the event object instead of input value (as it should do according to documentation). It also emits event when value after applying modifiers has not changed - i.e. when trailing spaces were added to the value of the text field with "trim" modifier. Input element fires the 'change' event, but the effective value (input.value.trim()) doesn't change

Second commit fixes the last issue, and the 3rd commit fixes the emitted value (input value instead of event object)

Playground.vue for testing:

<template>
    <v-container>
        <v-text-field v-model.trim="value" label="Input" @change="change($event)"></v-text-field>
        <p>Type 'abc' then blur, 'change' event should be emitted. Then add some spaces at the end and blur - change event should not be emitted</p>
    </v-container>
</template>


<script>
    export default {
        data: () => ({value: ''}),
        methods: {
            change: e => console.log('Event emitted', e)
        }
    }
</script>

@jacekkarczmarczyk jacekkarczmarczyk changed the title Fixes #1217 - change triggered on blur Fixes #1218 - change triggered on blur Aug 4, 2017
@jacekkarczmarczyk
Copy link
Member Author

Currently docs say that the "change" event emits String value, after merging this PR "change" event will emit String or Number (Number if v-model has "number" modifier), so I guess the docs should be updated as well

@johnleider
Copy link
Member

I had already fixed this issue, forgot to push. Thank you for your contribution however.

ba176f5

@johnleider johnleider closed this Aug 4, 2017
@jacekkarczmarczyk
Copy link
Member Author

@johnleider - it doesn't seem to be fixed for me. Try to use this Playground.vue I've provided, it still sometimes emits 2 events:

  • type "abc " (with spaces at the end)
  • blur - 2 events are emitted (one with event object, one with input value)
  • focus again and blur - event is still emitted although value hasn't changed

@johnleider
Copy link
Member

johnleider commented Aug 4, 2017 via email

@johnleider
Copy link
Member

johnleider commented Aug 4, 2017 via email

@jacekkarczmarczyk
Copy link
Member Author

To be precise - when I wrote "2 events are emitted" I meant "2 'change' events are emmited", I guest the 'blue' event also was emitted but I didn't check it

And in the last step I've also checked only 'change' event. It was emitted, but I'd expect only blur event if the value has not changed

My change also takes into account the "trim" or "number" modifier as I wrote before, so "a " and "a" values are equals (after trimming) so "change" event imho shouldn't be emitted

@johnleider
Copy link
Member

johnleider commented Aug 4, 2017 via email

@lock
Copy link

lock bot commented Apr 16, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. Please direct any non-bug questions to our Discord

@lock lock bot locked as resolved and limited conversation to collaborators Apr 16, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants