Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.

$dialog MessageBox -- should autofocus primary button, so [ENTER] or [SPACEBAR] works #144

@fredsa

Description

@fredsa
  1. Run the sample code from http://angular-ui.github.com/bootstrap/#/dialog

    var title = 'This is a message box';
    var msg = 'This is the content of the message box';
    var btns = [{result:'cancel', label: 'Cancel'}, {result:'ok', label: 'OK', cssClass: 'btn-primary'}];

    $dialog.messageBox(title, msg, btns)
    .open()
    .then(function(result){
    alert('dialog closed with result: ' + result);
    });

  2. Attempt to accept the default action using the keyboard -> Nothing happens

Possible way to improve message box:

  • recognize the 'btn-primary' class and set the 'autofocus' attribute automatically

  • add an additional 'autofocus' property, e.g.

    var btns = [{result:'cancel', label: 'Cancel'}, {result:'ok', label: 'OK', cssClass: 'btn-primary', autofocus: true}];

Additional ideas:

  • add general purpose keyboard shortcut (hotkey) functionality, e.g.

    var btns = [{result:'cancel', label: 'Cancel', 'hotkey': 'c'}, {result:'ok', label: 'OK', cssClass: 'btn-primary', hotkey: 'o'}];

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions