Skip to content

Commit edc9d8b

Browse files
committed
use composition input
1 parent 25728e5 commit edc9d8b

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

browser/main/TopBar/index.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import ee from 'browser/main/lib/eventEmitter'
77
import NewNoteButton from 'browser/main/NewNoteButton'
88
import i18n from 'browser/lib/i18n'
99
import debounce from 'lodash/debounce'
10+
import CInput from 'react-composition-input'
1011

1112
class TopBar extends React.Component {
1213
constructor (props) {
@@ -15,10 +16,7 @@ class TopBar extends React.Component {
1516
this.state = {
1617
search: '',
1718
searchOptions: [],
18-
isSearching: false,
19-
isAlphabet: false,
20-
isIME: false,
21-
isConfirmTranslation: false
19+
isSearching: false
2220
}
2321

2422
this.focusSearchHandler = () => {
@@ -30,6 +28,7 @@ class TopBar extends React.Component {
3028
this.handleSearchFocus = this.handleSearchFocus.bind(this)
3129
this.handleSearchBlur = this.handleSearchBlur.bind(this)
3230
this.handleSearchChange = this.handleSearchChange.bind(this)
31+
this.handleSearchClearButton = this.handleSearchClearButton.bind(this)
3332

3433
this.debouncedUpdateKeyword = debounce((keyword) => {
3534
this.context.router.push(`/searched/${encodeURIComponent(keyword)}`)
@@ -91,7 +90,7 @@ class TopBar extends React.Component {
9190
}
9291

9392
handleSearchChange (e) {
94-
const keyword = this.refs.searchInput.value
93+
const keyword = e.target.value
9594
this.debouncedUpdateKeyword(keyword)
9695
}
9796

@@ -130,7 +129,7 @@ class TopBar extends React.Component {
130129
}
131130

132131
handleCodeInit () {
133-
ee.emit('top:search', this.refs.searchInput.value)
132+
ee.emit('top:search', this.refs.searchInput.value || '')
134133
}
135134

136135
render () {
@@ -148,18 +147,18 @@ class TopBar extends React.Component {
148147
tabIndex='-1'
149148
ref='search'
150149
>
151-
<input
150+
<CInput
152151
ref='searchInput'
153152
value={this.state.search}
154-
onChange={(e) => this.debouncedUpdateKeyword(this.refs.searchInput.value)}
153+
onInputChange={this.handleSearchChange}
155154
onKeyDown={this.handleKeyDown}
156155
placeholder={i18n.__('Search')}
157156
type='text'
158157
className='searchInput'
159158
/>
160159
{this.state.search !== '' &&
161160
<button styleName='control-search-input-clear'
162-
onClick={this.handleSearchChange}
161+
onClick={this.handleSearchClearButton}
163162
>
164163
<i className='fa fa-fw fa-times' />
165164
<span styleName='control-search-input-clear-tooltip'>{i18n.__('Clear Search')}</span>

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "boost",
33
"productName": "Boostnote",
4-
"version": "0.11.16",
4+
"version": "0.11.16",
55
"main": "index.js",
66
"description": "Boostnote",
77
"license": "GPL-3.0",
@@ -101,6 +101,7 @@
101101
"react-autosuggest": "^9.4.0",
102102
"react-codemirror": "^0.3.0",
103103
"react-color": "^2.2.2",
104+
"react-composition-input": "^1.1.1",
104105
"react-debounce-render": "^4.0.1",
105106
"react-dom": "^15.0.2",
106107
"react-image-carousel": "^2.0.18",

yarn.lock

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7524,6 +7524,13 @@ react-color@^2.2.2:
75247524
reactcss "^1.2.0"
75257525
tinycolor2 "^1.4.1"
75267526

7527+
react-composition-input@^1.1.1:
7528+
version "1.1.1"
7529+
resolved "https://registry.yarnpkg.com/react-composition-input/-/react-composition-input-1.1.1.tgz#51fc711f8b1c7d11e39210639175f0b48de44aff"
7530+
integrity sha512-xzRAUvsrEdSjI1tQXu3ouPHkHVZnunx6OoAFsv4YxVV6fIBHc9XZuxkmJwoxSatPxJ6WN94k91PBWQTsL6h/ZA==
7531+
dependencies:
7532+
prop-types "^15.6.2"
7533+
75277534
react-css-modules@^3.7.6:
75287535
version "3.7.10"
75297536
resolved "https://registry.yarnpkg.com/react-css-modules/-/react-css-modules-3.7.10.tgz#300da561e550eeec5ebc0bc8c7d51d77d88ae2d7"

0 commit comments

Comments
 (0)