-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
<b-form-input> becoming out of sync with value if using formatter #2657
Comments
Is this occurring on a browser that supports autocomplete or predictive text? There is an issue with how some browsers handle these features. Some emit and I put for every character, while others will wait and emit a change once an autocomplete is completed or a space is entered (and inpput event may or may not be emitted with the change. |
I am using chrome 69 right now, but I am typing into the input without using any autocomplete. The updateValue function is being fired correctly on key press. The localValue could potentially not be different then the value passed into updateValue due to the formatter function. If that is the case the input's value needs to be updated to match the localValue/value param so they stay in sync. |
@tmorehouse I've looked into this a bit and I don't know why the input's value isn't changed. |
@tmorehouse is my proposed fixed as outlined earlier not what you guys are want to do? I see you added a test that seems to be similar to this issue at bootstrap-vue/src/components/form-input/form-input.spec.js Lines 483 to 501 in ec91788
Where it is asserting that the value TEST is still set as the input value. Although I am not sure if that is something you are specifically handling for when formatters return false. My issue is mainly coming from when my formatter is returning an empty string, which I think should force the input's value to also be an empty string and not to keep any characters the user may have typed into the input. |
Yeah, there may need to be a few tweaks to the formatter. Lazy formatting works best (as it doesn't cause issues with cursor positioning while the user types... even google libphonenumber has dropped as you type formatting). Typically, one could use the non lazy formatter to prevent certain characters to be type, by preventing default on the passed |
I just want to point out that this bug did not exist on version 2.0.0-rc.12, I updated from that yesterday and it broke, so I'm not exactly sure what version change caused it. |
I opened a new issue but then realized this is exactly the same. This hasn't been released yet, right? |
This has not been released yet, it will when @tmorehouse is done preparing the next release candidate. |
The issue is still here, because the input's isn't change the value on predictive text. |
@nevadavid Are you using v2.4.0? v2.4.0 includes PR #4701 to handle out of sync values |
@tmorehouse Yes, I use this version. The input's will changes just when I press space. |
@nevadavid can you create a minimal reproduction (jsFiddle, CodePen, or CodeSandBox - you can export from the docs playground) to illustrate what you are experiencing and open a new issue? |
@tmorehouse this is what I experience on official website: https://bootstrap-vue.js.org/docs/components/form-input |
I do not understand the issue you are having... can you explain more? i can type without problem into the inputs. |
@tmorehouse So when you enable the "Show correction suggestions" or similar function on your phone and type any characters on But here is my solution: https://codepen.io/nevadavid/pen/mdJbmgJ |
@nevadavid could you please open a new ticket with your issue, so we can track it? |
@tmorehouse I created a new issue: #4724 |
When a form-input has a formatter on it stripping out characters in the case of trying to only allowing numerial values in a text input, the input value can sometimes not match up with the emitted value.
codepen: https://codepen.io/Kalvens/pen/Lqabrj (type any nonnumerical character in the input)
browser: Chrome Version 69.0.3497.100 (Official Build) (64-bit)
OS: linux
I believe the issue comes from
bootstrap-vue/src/mixins/form-text.js
Lines 107 to 123 in a14245c
the value is already formatted at that point so if the formatter strips out all of the characters leaving the value to be an empty string, nothing will happen even though the input still has a value set for it
I was playing around with your source code and doing
seems to fix my issue, but I am not sure if that would be affecting anything else using the mixin.
The text was updated successfully, but these errors were encountered: