Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

md-select opens twice when ng-if and ng-disabled are combined #1852

Closed
gustavohenke opened this issue Mar 10, 2015 · 5 comments
Closed

md-select opens twice when ng-if and ng-disabled are combined #1852

gustavohenke opened this issue Mar 10, 2015 · 5 comments
Assignees
Milestone

Comments

@gustavohenke
Copy link

When you have a md-select that combines ng-if and ng-disabled, it's opened twice when you click on it.

The same issue is observed when using md-select with only ng-disabled and a parent element with ng-if.

Example plunkr (just click in one of the selects):
http://plnkr.co/edit/IMPaUh9KhyUxAxvTleAO?p=preview

Demo gif:

@rschmukler rschmukler self-assigned this Mar 10, 2015
@troch
Copy link
Contributor

troch commented Mar 11, 2015

Same problem here, when ng-disabled is added (in my case there is no ng-if), the dropdown menu opens twice.
Although, if the disabled attribute is present, md-select is styled but options can still be selected.

@ThomasBurleson ThomasBurleson modified the milestone: 0.9.0 Mar 11, 2015
@troch
Copy link
Contributor

troch commented Mar 11, 2015

The issue occurs when md-select is initially not disabled and ngDisabled is used, the $observe listener fires twice causing the click and key events listeners to be registered twice.

The solution (or hack?) is to track md-select disabled state and only register / de-register events if the disabled state has changed.

See pull request #1871

@MaximShoustin
Copy link

+1

@gustavohenke
Copy link
Author

@MaximShoustin this is already fixed in 0.9.0.

@brunofin
Copy link

@rschmukler

This issue still occurs with me on a md-select containing ng-disabled attribute with its md-option containing ng-selected attribute.

On AngularJS v1.4.6 and Angular Material Design v0.10.1

Example code:

<md-input-container>
              <label>Perfil</label>
              <md-select ng-model="selectedProfile" ng-disabled="{{ isProfileEditable() }}"> <!-- ng-disabled="{{ !isProfileEditable() }}" -->
                <md-option ng-repeat="_p in profile.profiles" value="{{ _p.id }}" ng-selected="{{ _p.id == profile.currentProfileId }}">
                  {{ _p.name }}
                </md-option>
              </md-select>
        </md-input-container>

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

No branches or pull requests

6 participants