Skip to content

wrong value using Switch or TextField(!) in combination with updateOn: 'blur' #1362

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

Open
gms1 opened this issue Jun 3, 2018 · 4 comments
Open

Comments

@gms1
Copy link

gms1 commented Jun 3, 2018

The first toggle seems to get lost. After that the value is 'true' if the switch is off and 'false' if the switch is on

This is the repo to reproduce this issue:
https://github.com/gms1/issues/tree/master/nativescript_angular/switch-updateOnBlur

@tsonevn tsonevn self-assigned this Jun 4, 2018
@tsonevn
Copy link
Contributor

tsonevn commented Jun 4, 2018

Hi @gms1,
Thank you for the sample project.
I tested this case while using the Switch component with '@angular/forms'. Indeed the valueChanges method will not be executed on first Switch value change. For further info, please keep track on the issue.

@gms1
Copy link
Author

gms1 commented Jun 10, 2018

Hi @tsonevn,

regarding Switch and other controls, I wondered how an "updateOn: blur" could work, as long as there are no focus/blur events from the underlying framework for these controls.
However, I am getting a similar behavior using Textfield, although focus/blur events are fully supported for this control.

In the repo there is now a new folder 'testfield-updateOnBlur' with which the problem with TextField can be reproduced.

Should I open a new issue for TextField?
For Switch / Slider, ... this feature may not be that important, but with TextField we are now forced to unnecessarily validate all typos, or to implement a workaround every time that bypasses the standard validation

@gms1 gms1 changed the title wrong value using Switch in combination with updateOn: 'blur' wrong value using Switch or TextField(!) in combination with updateOn: 'blur' Jun 11, 2018
@gms1
Copy link
Author

gms1 commented Jun 11, 2018

added TextField to the title

however, it is possible that the TextField-issue already has a solution:
#1230

see ControlValueAccessor

  * On blur (or equivalent), your class should call the registered function to allow
   * the forms API to update itself:
   *
   * ```ts
   * host: {
   *    '(blur)': '_onTouched()'
   * }
   * ```

@gms1
Copy link
Author

gms1 commented Jun 11, 2018

verified: #1230 solves the TextField-part of this issue!

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

No branches or pull requests

2 participants