Skip to content

b-input changes v-model from null to empty string on blur #6078

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

Closed
lucianobosco opened this issue Nov 23, 2020 · 5 comments · Fixed by #6084
Closed

b-input changes v-model from null to empty string on blur #6078

lucianobosco opened this issue Nov 23, 2020 · 5 comments · Fixed by #6084

Comments

@lucianobosco
Copy link

Describe the bug

By hydrating a b-input v-model with a null value and blurring the input with no changes, the object property is changed from null to an empty string "". This happens only the first time when the input is hydrated. If you hydrate it again with no page refresh, it works as expected.

Steps to reproduce the bug

  1. Hydrate the <b-input> with a null value for the v-model
  2. Focus the input
  3. Blur the input with no changes at all
  4. See how the property is changed from null to ""

Expected behavior

The object property must still as null

Versions

Libraries:

  • BootstrapVue: ~2.19.0
  • Bootstrap: ~4.4.1
  • Vue: ^2.6.12

Environment:

  • Device: Desktop
  • OS: Ubuntu 18
  • Browser: Chrome
  • Version: 86.0.4240.198 (Official Build) (64-bit)

Additional context

This is causing an issue with some 3rd party validators like vee-validate, where a pristine flag is set to false because changes were detected on the object (from null to "").

@lucianobosco lucianobosco changed the title b-input changing v-model from null to empty string on blur b-input changes v-model from null to empty string on blur Nov 23, 2020
@jacobmllr95
Copy link
Member

@lucianobosco Can you create a minimal reproduction fo the issue on CodePen or CodeSanbox?

@lucianobosco
Copy link
Author

@jackmu95 Hope it helps!
Please note that the issue happens the first time (on mounted) and when hydrating a null description after having a non null description already hydrated.

https://codepen.io/lucianobosco/pen/xxOvJWv

@jacobmllr95
Copy link
Member

@lucianobosco Can you please confirm that this CodeSanbox with the changes of the linked PR applied solves the issue:
https://codesandbox.io/s/bootstrapvue-starter-project-forked-kf5vp?file=/App.vue

@lucianobosco
Copy link
Author

@jackmu95 thanks! This is working as expected.
Will this fix be included in the next release?

@jacobmllr95
Copy link
Member

@lucianobosco Yeah :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants