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

[Ionic v4.0.0-beta.11] ion-select form.patchValue #15613

Closed
matthew-valenti opened this issue Sep 16, 2018 · 2 comments
Closed

[Ionic v4.0.0-beta.11] ion-select form.patchValue #15613

matthew-valenti opened this issue Sep 16, 2018 · 2 comments
Labels
needs: reply the issue needs a response from the user

Comments

@matthew-valenti
Copy link

Bug Report

Ionic Info

Ionic:
   ionic (Ionic CLI)          : 4.1.2 (C:\Users\matth\AppData\Roaming\npm\node_modules\ionic)
   Ionic Framework            : @ionic/angular 4.0.0-beta.11
   @angular-devkit/core       : 0.7.4
   @angular-devkit/schematics : 0.7.4
   @angular/cli               : 6.1.4
   @ionic/ng-toolkit          : 1.0.7
   @ionic/schematics-angular  : 1.0.5

System:
   NodeJS : v8.9.4 (C:\Program Files\nodejs\node.exe)
   npm    : 5.6.0
   OS     : Windows 10

Describe the Bug
The ion-select component on a reactive form does not work correctly with form.patchValue. After a patch, sometimes the ion-select shows the value selected and sometimes it doesn't.

2018-09-15_1813

Steps to Reproduce
Steps to reproduce the behavior:

  1. Create a blank app.
  2. Create a reactive form with an ion-select control. Use code in this ticket [Ionic v4.0.0-beta.7] ion-select form control dirty #15572
  3. Add form.patchValue i.e.
ngOnInit() {

    this.form = this.formBuilder.group({
        languageCode: ['', Validators.compose([Validators.required])]
    });

    this.form.patchValue({
        languageCode: 'en'
    });
}
  1. It's difficult to reproduce this consistently. I found the best way was to simply refresh the page over and over again until ion-select doesn't display a value.

Expected Behavior
The ion-select component displays a value after form.patchValue

Additional Context
With a small list like this example 1 out of ~30 page refreshes resulted in this behavior. With larger lists and doing the patch in an observable subscribe failed 1 out of 3 times.

It appears to be a race condition issue. If I wrap the patch in a short delay the ion-select displays correctly every time. e.g.

setTimeout(
	function () {
		that.form.patchValue({
			name: data.name,
			locationId: data.locationId
		});
}, 5);
@ionitron-bot ionitron-bot bot added the triage label Sep 16, 2018
@paulstelzer
Copy link
Contributor

Thanks for the issue! Are you still seeing this problem in latest, 4.0.0-beta.17?

@paulstelzer paulstelzer added needs: reply the issue needs a response from the user and removed triage labels Dec 4, 2018
@ionitron-bot
Copy link

ionitron-bot bot commented Jan 3, 2019

Thanks for the issue! This issue is being closed due to the lack of a reply. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

Thank you for using Ionic!

@ionitron-bot ionitron-bot bot closed this as completed Jan 3, 2019
@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Jan 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs: reply the issue needs a response from the user
Projects
None yet
Development

No branches or pull requests

2 participants