Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1066)

Unified Diff: pkg/dartdoc/lib/src/client/dropdown.dart

Issue 11038035: Avoid capture of 's' in dartdoc search input. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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. */
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698