Issue metadata
Sign in to add a comment
|
[Dialogs] Add a universal Enter handler for cr-dialog |
||||||||||||||||||||||
Issue descriptionCurrently we have a mishmash of onKeypress and iron-a11y-keys to handle the Enter key in MD Settings dialogs. We can update cr-dialog to have a universal handler following the example here: https://cs.chromium.org/chromium/src/ui/webui/resources/js/cr/ui/overlay.js?q=overlay.js&sq=package:chromium&l=58 We need to come up with a way of either tagging or finding the default button.
,
Jan 26 2017
^ Great thoughts.
,
Jan 26 2017
,
Jan 27 2017
this might help guide someone on this quest: https://cs.chromium.org/chromium/src/ui/webui/resources/js/cr/ui/overlay.js?q=ui/webui/resources/js/cr/ui/overlay.js&sq=package:chromium&dr&l=60
,
Feb 9 2017
tommycli@: how many dialogs in md-settings currently don't have good default Enter handling?
,
Feb 9 2017
They should all have Enter handlers now. They're just all implemented per-instance.
,
Feb 9 2017
ah, nvm then
,
Feb 14 2017
,
Feb 14 2017
,
Feb 15 2018
This issue has been Available for over a year. If it's no longer important or seems unlikely to be fixed, please consider closing it out. If it is important, please re-triage the issue. Sorry for the inconvenience if the bug really should have been left as Available. If you change it back, also remove the "Hotlist-Recharge-Cold" label. For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
,
May 1 2018
@tommy: Is this bug a duplicate of issue 626420? Can we dedup? If not, is there anything left to do here?
,
May 1 2018
|
|||||||||||||||||||||||
►
Sign in to add a comment |
|||||||||||||||||||||||
Comment 1 by dpa...@chromium.org
, Jan 26 2017Perhaps just querying the cr-dialog's DOM for the "action-button" CSS class could be a way to find the default button. Then we could query whether this button is enabled and if enabled, simulate a click/tap on it. A different approach I had thought initially here, for discussion (perhaps more complicated than previous one). We could add two new methods to cr-dialog, canSubmit() and submit(). The default implementations will be canSubmit: function() { return false; } submit: function() { // no-op; } Users of cr-dialog are not subclasses, just instances of <cr-dialog> itself, so in order to override those methods they would need to do something as follows. myDialog.canSubmit = function() { /* validation logic here */ }; myDialog.submit = function() { /* perform submit action here */ }; When an 'Enter' key is detected, the cr-dialog would simply do if (this.canSubmit() && !this.forbiddenTagnames.has(e.target.tagName)) this.submit(); where forbiddenTagnames is similar to the link posted by @tommycli above. Finally that entire functionality would be opt-in as follows <dialog is="cr-dialog" submit-on-enter>...</dialog>