Skip to content

Commit

Permalink
Keyboard shortcuts should never focus the editor
Browse files Browse the repository at this point in the history
Paired with @alexgchacon

Fixes #74
  • Loading branch information
eee-c committed Feb 21, 2014
1 parent 2a32d82 commit c242a9f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/full.dart
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ changed.''';

_attachKeyboardHandlers() {
Keys.shortcuts({
'Ctrl+N, Ctrl+O, ⌘+O, Ctrl+Shift+H': _hideDialog
'Ctrl+N, Ctrl+O, ⌘+O, Ctrl+Shift+H': ()=> _hideDialog(focus: false)
});
Keys.shortcuts({
'Esc': ()=> _hideDialog(),
Expand Down
35 changes: 29 additions & 6 deletions test/full/keyboard_shortcuts_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,35 @@ keyboard_shortcuts_tests() {
editor.store..clear()..freeze();
});

test("can open the new dialog", (){
helpers.typeCtrl('n');
expect(
queryAll('button'),
helpers.elementsContain('Save')
);

group("opening the new dialog", (){
setUp((){
var preview_ready = new Completer();
editor.onPreviewChange.listen((e){
preview_ready.complete();
});
return preview_ready.future;
});

test("can open the new dialog", (){
helpers.typeCtrl('n');
expect(
queryAll('button'),
helpers.elementsContain('Save')
);
});

test("opening new project gives input field focus", (){
helpers.typeCtrl('n');

var wait = new Duration(milliseconds: 500);
new Timer(wait, expectAsync0((){
expect(
document.activeElement,
equals(query('.ice-dialog input[type=text]'))
);
}));
});
});

group("Open Projects Dialog", (){
Expand Down
2 changes: 2 additions & 0 deletions test/full/new_project_dialog_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ new_project_dialog_tests(){
editor.store..clear()..freeze();
});

// TODO: see keyboard shortcut tests for more realistic setup and apply same
// approach here.
test("new project input field has focus", (){
helpers.click('button', text: '☰');
helpers.click('li', text: 'New');
Expand Down

0 comments on commit c242a9f

Please sign in to comment.