diff --git a/browser/main/TopBar/index.js b/browser/main/TopBar/index.js index added48f..8be58a63 100644 --- a/browser/main/TopBar/index.js +++ b/browser/main/TopBar/index.js @@ -24,14 +24,20 @@ class TopBar extends React.Component { this.newNoteHandler = () => { this.handleNewPostButtonClick() } + + this.focusSearchHandler = () => { + this.handleFocusSearch() + } } componentDidMount () { ee.on('top:new-note', this.newNoteHandler) + ee.on('top:focus-search', this.focusSearchHandler) } componentWillUnmount () { ee.off('top:new-note', this.newNoteHandler) + ee.off('top:focus-search', this.focusSearchHandler) } handleNewPostButtonClick (e) { @@ -244,6 +250,10 @@ class TopBar extends React.Component { }) } + handleFocusSearch () { + this.refs.search.childNodes[0].focus() + } + render () { let { config, style, data } = this.props let searchOptionList = this.getOptions() @@ -287,6 +297,7 @@ class TopBar extends React.Component { onChange={(e) => this.handleSearchChange(e)} placeholder='Search' type='text' + id='Search' /> {this.state.searchPopupOpen &&
diff --git a/lib/main-menu.js b/lib/main-menu.js index 11f182d7..e554e98a 100644 --- a/lib/main-menu.js +++ b/lib/main-menu.js @@ -143,6 +143,16 @@ var view = { click: function () { BrowserWindow.getFocusedWindow().toggleDevTools() } + }, + { + type: 'separator' + }, + { + label: 'Focus Search', + accelerator: 'Control + S', + click: function () { + mainWindow.webContents.send('top:focus-search') + } } ] }