@@ -7,6 +7,7 @@ import ee from 'browser/main/lib/eventEmitter'
7
7
import NewNoteButton from 'browser/main/NewNoteButton'
8
8
import i18n from 'browser/lib/i18n'
9
9
import debounce from 'lodash/debounce'
10
+ import CInput from 'react-composition-input'
10
11
11
12
class TopBar extends React . Component {
12
13
constructor ( props ) {
@@ -15,10 +16,7 @@ class TopBar extends React.Component {
15
16
this . state = {
16
17
search : '' ,
17
18
searchOptions : [ ] ,
18
- isSearching : false ,
19
- isAlphabet : false ,
20
- isIME : false ,
21
- isConfirmTranslation : false
19
+ isSearching : false
22
20
}
23
21
24
22
this . focusSearchHandler = ( ) => {
@@ -30,6 +28,7 @@ class TopBar extends React.Component {
30
28
this . handleSearchFocus = this . handleSearchFocus . bind ( this )
31
29
this . handleSearchBlur = this . handleSearchBlur . bind ( this )
32
30
this . handleSearchChange = this . handleSearchChange . bind ( this )
31
+ this . handleSearchClearButton = this . handleSearchClearButton . bind ( this )
33
32
34
33
this . debouncedUpdateKeyword = debounce ( ( keyword ) => {
35
34
this . context . router . push ( `/searched/${ encodeURIComponent ( keyword ) } ` )
@@ -91,7 +90,7 @@ class TopBar extends React.Component {
91
90
}
92
91
93
92
handleSearchChange ( e ) {
94
- const keyword = this . refs . searchInput . value
93
+ const keyword = e . target . value
95
94
this . debouncedUpdateKeyword ( keyword )
96
95
}
97
96
@@ -130,7 +129,7 @@ class TopBar extends React.Component {
130
129
}
131
130
132
131
handleCodeInit ( ) {
133
- ee . emit ( 'top:search' , this . refs . searchInput . value )
132
+ ee . emit ( 'top:search' , this . refs . searchInput . value || '' )
134
133
}
135
134
136
135
render ( ) {
@@ -148,18 +147,18 @@ class TopBar extends React.Component {
148
147
tabIndex = '-1'
149
148
ref = 'search'
150
149
>
151
- < input
150
+ < CInput
152
151
ref = 'searchInput'
153
152
value = { this . state . search }
154
- onChange = { ( e ) => this . debouncedUpdateKeyword ( this . refs . searchInput . value ) }
153
+ onInputChange = { this . handleSearchChange }
155
154
onKeyDown = { this . handleKeyDown }
156
155
placeholder = { i18n . __ ( 'Search' ) }
157
156
type = 'text'
158
157
className = 'searchInput'
159
158
/>
160
159
{ this . state . search !== '' &&
161
160
< button styleName = 'control-search-input-clear'
162
- onClick = { this . handleSearchChange }
161
+ onClick = { this . handleSearchClearButton }
163
162
>
164
163
< i className = 'fa fa-fw fa-times' />
165
164
< span styleName = 'control-search-input-clear-tooltip' > { i18n . __ ( 'Clear Search' ) } </ span >
0 commit comments