Chromium Code Reviews| Index: pkg/dartdoc/lib/src/client/dropdown.dart |
| diff --git a/pkg/dartdoc/lib/src/client/dropdown.dart b/pkg/dartdoc/lib/src/client/dropdown.dart |
| index eab7e7901b8be63d230736461329f6f5120abd42..7caa931b98e86638a528f6574c628a878aa212f7 100644 |
| --- a/pkg/dartdoc/lib/src/client/dropdown.dart |
| +++ b/pkg/dartdoc/lib/src/client/dropdown.dart |
| @@ -322,10 +322,15 @@ void hideDropDown() { |
| dropdown.style.visibility = 'hidden'; |
| } |
| +bool searchInputFocused = false; |
|
Jennifer Messerly
2012/10/04 20:31:17
this works, but there are a few other ways that mi
Johnni Winther
2012/10/05 12:51:37
Thanks. I've put this is in https://codereview.chr
|
| + |
| /** Activate search on Ctrl+3 and S. */ |
| void shortcutHandler(KeyboardEvent event) { |
| - if (event.keyCode == 0x33/* 3 */ && event.ctrlKey || |
| - event.keyCode == 0x53/* S */) { |
| + if (event.keyCode == 0x33/* 3 */ && event.ctrlKey) { |
| + searchInput.focus(); |
| + event.preventDefault(); |
| + } else if (!searchInputFocused && event.keyCode == 0x53/* S */) { |
| + // Avoid preventing writing 's' in the search input. |
| searchInput.focus(); |
| event.preventDefault(); |
| } |
| @@ -336,6 +341,9 @@ void shortcutHandler(KeyboardEvent event) { |
| */ |
| void setupShortcuts() { |
| window.on.keyDown.add(shortcutHandler); |
| + searchInput = query('#q'); |
| + searchInput.on.focus.add((event) => searchInputFocused = true); |
|
Jennifer Messerly
2012/10/04 20:31:17
with changes described above, you won't need these
Johnni Winther
2012/10/05 12:51:37
Done.
|
| + searchInput.on.blur.add((event) => searchInputFocused = false); |
| } |
| /** Setup search hooks. */ |