diff --git a/browser/main/NoteList/index.js b/browser/main/NoteList/index.js index e97f7aef..9b9f9b1c 100644 --- a/browser/main/NoteList/index.js +++ b/browser/main/NoteList/index.js @@ -326,8 +326,10 @@ class NoteList extends React.Component { } if (location.pathname.match(/\/searched/)) { - const searchInputText = document.getElementsByClassName('searchInput')[0].value - if (searchInputText === '') { + const searchInputText = params.searchword + const allNotes = data.noteMap.map((note) => note) + this.contextNotes = allNotes + if (searchInputText === undefined || searchInputText === '') { return this.sortByPin(this.contextNotes) } return searchFromNotes(this.contextNotes, searchInputText) diff --git a/browser/main/TopBar/index.js b/browser/main/TopBar/index.js index 86cc6b2a..ae4d9664 100644 --- a/browser/main/TopBar/index.js +++ b/browser/main/TopBar/index.js @@ -28,6 +28,14 @@ class TopBar extends React.Component { } componentDidMount () { + const { params } = this.props + const searchWord = params.searchword + if (searchWord !== undefined) { + this.setState({ + search: searchWord, + isSearching: true + }) + } ee.on('top:focus-search', this.focusSearchHandler) ee.on('code:init', this.codeInitHandler) } @@ -97,9 +105,10 @@ class TopBar extends React.Component { this.setState({ isConfirmTranslation: true }) - router.push('/searched') + const keyword = this.refs.searchInput.value + router.push(`/searched/${encodeURIComponent(keyword)}`) this.setState({ - search: this.refs.searchInput.value + search: keyword }) } } @@ -108,7 +117,7 @@ class TopBar extends React.Component { const { router } = this.context const keyword = this.refs.searchInput.value if (this.state.isAlphabet || this.state.isConfirmTranslation) { - router.push('/searched') + router.push(`/searched/${encodeURIComponent(keyword)}`) } else { e.preventDefault() } diff --git a/browser/main/index.js b/browser/main/index.js index d9c7456e..ae906538 100644 --- a/browser/main/index.js +++ b/browser/main/index.js @@ -64,7 +64,9 @@ ReactDOM.render(( - + + +