material icon indicating copy to clipboard operation
material copied to clipboard

Alert and confirm -dialogs throw errors

Open chronixlo opened this issue 11 years ago • 5 comments

Since 0.11.0(-rc?) my alert and confirm dialogs have been throwing Cannot read property '$eval' of undefined at angular-material.js:660

Custom dialogs are working as before.

I'm guessing it has something to do with the new md-autofocus attr. I can't reproduce the issue outside of the app I'm working.

Worked around the problem by adding focusOnOpen: false

chronixlo avatar Sep 10 '15 04:09 chronixlo

This is a logic issue with $mdUtil.findFocusTarget( )

ThomasBurleson avatar Sep 10 '15 13:09 ThomasBurleson

there still seems to be an issue with the alert and confirm dialogs when debug info is disabled.

Code Pen: http://codepen.io/anon/pen/BoopZj

It appears to be related to the confirm dialog template: md-autofocus="dialog.$type!='confirm'">. The end result is in function below it.scope() is undefined.

findFocusTarget: function(containerEl, attributeVal) {
  var elToFocus, items = containerEl[0].querySelectorAll(attributeVal || '[md-autofocus]');

  // Find the last child element with the focus attribute
  items.length && angular.forEach(items, function(it) {
    it = angular.element(it);

    // If the expression evaluates to FALSE, then it is not focusable target
    var focusExpression = it[0].getAttribute('md-autofocus');
    var isFocusable = focusExpression ? (it.scope().$eval(focusExpression) !== false ) : true;

    if (isFocusable) elToFocus = it;
  });

  return elToFocus;
},

rrajewski avatar Sep 10 '15 16:09 rrajewski

+1, I still have the same issue with the latest master

hodeyp avatar Sep 12 '15 10:09 hodeyp

@rrajewski - Your comments are very helpful and provide important specifics. Thank you. Re-opening.

ThomasBurleson avatar Sep 12 '15 13:09 ThomasBurleson

$compileProvider explains that $compileProvider.debugInfoEnabled(false) will make the scope() function return undefined: @see https://github.com/angular/angular.js/commit/dbbe6b3831e9e3545e3fae6d109aab6251131d82

ThomasBurleson avatar Sep 18 '15 13:09 ThomasBurleson