likeastore / ngDialog

Modals and popups provider for Angular.js applications
http://likeastore.github.io/ngDialog
3.14k stars 692 forks source link

Aria role wrong with ariaAuto #557

Open skarkkai opened 7 years ago

skarkkai commented 7 years ago

What version of ng-dialog are you using?

1.3.0

What version of AngularJS are you using?

1.6.4

What browsers are affected?

At least latest Chrome and Firefox on Linux.

Please describe the issue

Aria role attribute is always set to alertdialog when ariaAuto is true (and no ariaRole parameter passed), even though the dialog has many input fields.

According to my testing, this appears to be because inputs' offsetWidth and offsetHeight are 0 at the time getFocusableElements() is called from applyAriaAttributes(). When getFocusableElements() is called later from elsewhere, offsetWidth and offsetHeight are non-zero.

I assume this is because during the first call, the browser hasn't yet rendered the elements, and so they don't have positioning-related attributes. The problem disappears if I change the call

privateMethods.applyAriaAttributes($dialog, options);

to

setTimeout(function(){
    privateMethods.applyAriaAttributes($dialog, options);
}, 100);