File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -326,8 +326,10 @@ class NoteList extends React.Component {
326326 }
327327
328328 if ( location . pathname . match ( / \/ s e a r c h e d / ) ) {
329- const searchInputText = document . getElementsByClassName ( 'searchInput' ) [ 0 ] . value
330- if ( searchInputText === '' ) {
329+ const searchInputText = params . searchword
330+ const allNotes = data . noteMap . map ( ( note ) => note )
331+ this . contextNotes = allNotes
332+ if ( searchInputText === undefined || searchInputText === '' ) {
331333 return this . sortByPin ( this . contextNotes )
332334 }
333335 return searchFromNotes ( this . contextNotes , searchInputText )
Original file line number Diff line number Diff line change @@ -28,6 +28,14 @@ class TopBar extends React.Component {
2828 }
2929
3030 componentDidMount ( ) {
31+ const { params } = this . props
32+ const searchWord = params . searchword
33+ if ( searchWord !== undefined ) {
34+ this . setState ( {
35+ search : searchWord ,
36+ isSearching : true
37+ } )
38+ }
3139 ee . on ( 'top:focus-search' , this . focusSearchHandler )
3240 ee . on ( 'code:init' , this . codeInitHandler )
3341 }
@@ -97,9 +105,10 @@ class TopBar extends React.Component {
97105 this . setState ( {
98106 isConfirmTranslation : true
99107 } )
100- router . push ( '/searched' )
108+ const keyword = this . refs . searchInput . value
109+ router . push ( `/searched/${ encodeURIComponent ( keyword ) } ` )
101110 this . setState ( {
102- search : this . refs . searchInput . value
111+ search : keyword
103112 } )
104113 }
105114 }
@@ -108,7 +117,7 @@ class TopBar extends React.Component {
108117 const { router } = this . context
109118 const keyword = this . refs . searchInput . value
110119 if ( this . state . isAlphabet || this . state . isConfirmTranslation ) {
111- router . push ( ' /searched' )
120+ router . push ( ` /searched/ ${ encodeURIComponent ( keyword ) } ` )
112121 } else {
113122 e . preventDefault ( )
114123 }
Original file line number Diff line number Diff line change @@ -64,7 +64,9 @@ ReactDOM.render((
6464 < IndexRedirect to = '/home' />
6565 < Route path = 'home' />
6666 < Route path = 'starred' />
67- < Route path = 'searched' />
67+ < Route path = 'searched' >
68+ < Route path = ':searchword' />
69+ </ Route >
6870 < Route path = 'trashed' />
6971 < Route path = 'alltags' />
7072 < Route path = 'tags' >
You can’t perform that action at this time.
0 commit comments