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

"Attempting to select choice already selected" in console when using Formio component #109

Closed
sgronblo opened this issue Nov 7, 2017 · 2 comments

Comments

@sgronblo
Copy link

sgronblo commented Nov 7, 2017

The project I'm working on is experiencing this warning. It doesn't seem to cause any actual problem except clogging up the console with warnings that don't contribute any useful information.

Preconditions:

  • A select field with a default value

This could potentially be a problem in formio.js.

If I am understanding correctly, rendering this Formio component results in a call to createForm inside of formio.js's formio.form.js. This code looks like the following:

  createForm(form) {
    /**
     * {@link BaseComponent.component}
     */
    if (this.component) {
      this.component.components = form.components;
    }
    else {
      this.component = form;
    }
    return this.onFormBuild = this.render().then(() => {
      this.formReadyResolve();
      this.onFormBuild = null;
      this.setSubmission(this._submission);
    },
      (err) => this.formReadyReject(err)
    ).catch(
      (err) => this.formReadyReject(err)
    );
  }

I think this.render() indirectly results in a call to setValue on the Select which is fine the first time since no value is selected yet. However in the callback for render there is also a call to this.setSubmission(this._submission) which also indirectly results in a call to setValue which is trying to set the selected value to something that was already selected when rendering which results in this warning showing up.

Any suggestions what the cleanest way to fix this could be? Is there anything else I should be checking?

@randallknutson
Copy link
Contributor

We did some work recently in formio.js to fix the unhandled promise errors. Can you double check if this is still occurring?

@sgronblo
Copy link
Author

sgronblo commented Aug 6, 2018

Sorry, I'm not involved in the same project any more.

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

No branches or pull requests

2 participants