File tree Expand file tree Collapse file tree 3 files changed +18
-2
lines changed Expand file tree Collapse file tree 3 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,9 @@ class app.views.Search extends app.View
30
30
.on ' results' , @onResults
31
31
.on ' end' , @onEnd
32
32
33
+ @scope
34
+ .on ' change' , @onScopeChange
35
+
33
36
app .on ' ready' , @onReady
34
37
$ .on window , ' hashchange' , @searchUrl
35
38
$ .on window , ' focus' , @onWindowFocus
@@ -138,6 +141,11 @@ class app.views.Search extends app.View
138
141
$ .stopEvent (event)
139
142
return
140
143
144
+ onScopeChange : =>
145
+ @value = ' '
146
+ @ onInput ()
147
+ return
148
+
141
149
afterRoute : (name , context ) =>
142
150
return if app .shortcuts .eventInProgress ? .name is ' escape'
143
151
@ reset (true ) if not context .init and app .router .isIndex ()
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ class app.views.SearchScope extends app.View
6
6
tag : ' ._search-tag'
7
7
8
8
@events :
9
+ click : ' onClick'
9
10
keydown : ' onKeydown'
10
11
11
12
@routes :
@@ -87,11 +88,17 @@ class app.views.SearchScope extends app.View
87
88
@ trigger ' change' , null , previousDoc
88
89
return
89
90
91
+ onClick : (event ) =>
92
+ if event .target is @tag
93
+ @ reset ()
94
+ $ .stopEvent (event)
95
+ return
96
+
90
97
onKeydown : (event ) =>
91
98
if event .which is 8 # backspace
92
- if @doc and not @input .value
93
- $ .stopEvent (event)
99
+ if @doc and @input .selectionEnd is 0
94
100
@ reset ()
101
+ $ .stopEvent (event)
95
102
else if not @doc and @input .value
96
103
return if event .ctrlKey or event .metaKey or event .altKey or event .shiftKey
97
104
if event .which is 9 or # tab
Original file line number Diff line number Diff line change 215
215
color : var (--textColorLight );
216
216
background : var (--searchTagBackground );
217
217
border-radius : 2px ;
218
+ cursor : pointer ;
218
219
@extend %truncate-text ;
219
220
}
You can’t perform that action at this time.
0 commit comments