-
Notifications
You must be signed in to change notification settings - Fork 3.4k
$mdDialog doesn't play well with forms #1190
Comments
Focus is set in the modal for accessibility purposes, but it does make sense to make the focusable element configurable. Maybe people want to send focus to a heading with
|
Alright, supporting As for the key, I meant using the Enter key while the focus is elsewhere in the dialog. It would obviate the need of a |
I thought about this some more and I think it would be great if angular could facilitate the HTML5 http://caniuse.com/#feat=autofocus attribute. The directive is very simple: https://gist.github.com/mlynch/dd407b93ed288d499778 - should this be part of Angular proper? That leaves just the not-stealing-focus in |
I just created angular/angular#455 for the support in Angular proper. |
Beware that angular/angular is Angular 2.0 ;) |
@gustavohenke argh thanks, I was wondering why there was no other issue mentioning it 😅. angular/angular.js#10833 is the new one. |
Deferring to this 0.9 while we wait to hear back from the angular team. @robertmesserle any word? |
In the meantime, I think it would be great to have an option to deactivate the autofocus :) |
After some thoughts, I think the easiest and more generic way to handle this is to broadcast an event 'scope.$broadcast('dialog-showed');' at the end of the onShow function of the dialog. After catching this event, we would be able to change the focus or do whatever we want on the dialog. What do you think ? the line to write this broadcast: https://github.com/angular/material/blob/master/src/components/dialog/dialog.js#L441 I can do a PR with the modifications if you want. |
I would still prefer declarative focus, either by the workaround of tab On Mon, Feb 16, 2015, 7:20 PM Michel Vidailhet notifications@github.com
|
I am with wmertens on this. I would also prefer declarative. Until we actually agree on the proper solution, could we maybe already all agree that it is not ok for the closeButton to steal the focus? At least each person could implement their solution until there is a "beautiful" way of setting this up. Right now it just steals away the focus and work arounds seem truly ugly. Mean-time I am just commenting out line 375 of dialog/dialog.js.. :) Thanks for the beautiful work. I really am enjoying using md-angular. |
There is already an option in dialog setup called |
Reference #2313. |
Thank you marcysutton. Happy there is focusOnOpen and that we are looking at a md-sidenav-focus like solution. A small side note is that I could not find the focusOnOpen change in the CHANGELOG.md. Should it maybe go in there? |
Not a bad idea. It was documented in a commit, although explicitly calling out |
We will be adding a |
Updated with SHA 5fc572d |
…md-auto-focus` Provide a consistent approach to optionally specify child element that should be focused for any component. When the owning component is ready, use `$mdUtil.findFocusTarget()` * Bottomsheet and sideNav allows any child element to be the auto-focus target; using `md-auto-focus` * Sidenav Basic Usage demo specifies `md-auto-focus` on the input form element. * Bottomsheet Basic Usage demo shows expression use with `md-auto-focus` to conditional focus an element within ng-repeat. * Dialog allows custom dialog content to specify an `md-auto-focus` target for any content element. * Basic Demo uses `md-auto-focus` on first action button BREAKING CHANGE: md-autocomplete's `md-autofocus` has changed to `md-enable-autofocus`; to differentiate use with the new `md-auto-focus` indicator. Change your code from this: ```html <md-autocomplete md-autofocus> ``` To this: ```html <md-autocomplete md-enable-autofocus> ``` Fixes angular#1190.
See http://jsfiddle.net/p02Ls1dh/3/
mdDialog would be perfect for a quick entry panel, but it sets focus on the last button by default and if you try to use <form> for handling submit it breaks.
So maybe
$mdDialog
should:.md-dialog-focus
class to set the focus.dialog-close
button.md-dialog-close
?material/src/components/dialog/dialog.js
Line 373 in 01bbc4c
PS: I needed to put
type=button
on the cancel md-button so the form wouldn't click Cancel but Submit when typing<Enter>
. Is that a bug with md-button or is that expected?The text was updated successfully, but these errors were encountered: