Skip to content

md-select with ngModel freezes browser if other errors #2950

Closed

Description

@emin93

Bug, feature request, or proposal:

Bug

What is the expected behavior?

Normal Angular2 unhandled error in console output

What is the current behavior?

Browser/tab freezes

What are the steps to reproduce?

Simple md-select with an ngModel and another component after the md-select which throws an error.

WARNING: If you open the following plunker template, your browser/tab WILL FREEZE (tested in Chrome and Safari)
Plunker template: https://embed.plnkr.co/BARX13/

Activity

  1. emin93 commented on Feb 6, 2017

    @emin93
    Author

    Here is the Plunker link without preview, so code inspection is possible without tab freezing: https://plnkr.co/edit/BARX13?p=info

  2. crisbeto commented on Feb 6, 2017

    @crisbeto
    Member

    Great catch. This should be fixed in #2722, but I'll check if I can backport it to master as well.

  3. added a commit that references this issue on Feb 6, 2017
    8ee1edc
  4. self-assigned this
    on Feb 6, 2017
  5. changed the title [-]md-select with ngModel freezes browser[/-] [+]md-select with ngModel freezes browser if other errors[/+] on Feb 7, 2017
  6. added
    P3
    on Feb 7, 2017
  7. mrlund commented on Feb 7, 2017

    @mrlund

    Seems related to #2716 - I think the issue is the infinite loop caused when another error on the page prevents the MdSelect from rendering its options, and thus passing the if (!this.options) clause.

        /**
         * Sets the select's value. Part of the ControlValueAccessor interface
         * required to integrate with Angular's core forms API.
         *
         * @param value New value to be written to the model.
         */
        MdSelect.prototype.writeValue = function (value) {
            var _this = this;
            if (!this.options) {
                // In reactive forms, writeValue() will be called synchronously before
                // the select's child options have been created. It's necessary to call
                // writeValue() again after the options have been created to ensure any
                // initial view value is set.
                Promise.resolve(null).then(function () { return _this.writeValue(value); });
                return;
            }
            this._setSelectionByValue(value);
        };
    
  8. added a commit that references this issue on Feb 7, 2017
    a8cbd0a
  9. added a commit that references this issue on Feb 9, 2017
    998a583
  10. angular-automatic-lock-bot commented on Sep 5, 2019

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  11. locked and limited conversation to collaborators on Sep 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P3

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions