Skip to content

Commit 60e551e

Browse files
committed
Key入力の動き改善
- Searchに内容がある時にEscを押すと内容をSearchの内容を削除する - Cmd + Fを押すとSearch inputがfocusされる
1 parent 954e148 commit 60e551e

3 files changed

Lines changed: 17 additions & 3 deletions

File tree

browser/main/HomePage.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class HomePage extends React.Component {
3434
let { nav, top, list, detail } = this.refs
3535

3636
if (top.isInputFocused() && !e.metaKey) {
37-
if (e.keyCode === 13 || e.keyCode === 27) top.blurInput()
37+
if (e.keyCode === 13 || e.keyCode === 27) top.escape()
3838
return
3939
}
4040

@@ -68,7 +68,7 @@ class HomePage extends React.Component {
6868
}
6969

7070
// `detail`の`openDeleteConfirmMenu`が`true`なら呼ばれない。
71-
if (e.keyCode === 27) {
71+
if (e.keyCode === 27 || (e.keyCode === 70 && e.metaKey)) {
7272
top.focusInput()
7373
}
7474

browser/main/HomePage/ArticleList.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,17 @@ export default class ArticleList extends React.Component {
1515
clearInterval(this.refreshTimer)
1616
}
1717

18+
// 移動ができなかったらfalseを返す:
1819
selectPriorArticle () {
1920
let { articles, activeArticle, dispatch } = this.props
2021
let targetIndex = articles.indexOf(activeArticle) - 1
2122
let targetArticle = articles[targetIndex]
2223

2324
if (targetArticle != null) {
2425
dispatch(switchArticle(targetArticle.key))
26+
return true
2527
}
28+
return false
2629
}
2730

2831
selectNextArticle () {
@@ -32,7 +35,9 @@ export default class ArticleList extends React.Component {
3235

3336
if (targetArticle != null) {
3437
dispatch(switchArticle(targetArticle.key))
38+
return true
3539
}
40+
return false
3641
}
3742

3843
handleArticleClick (article) {

browser/main/HomePage/ArticleTopBar.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
import React, { PropTypes } from 'react'
22
import ReactDOM from 'react-dom'
33
import ExternalLink from 'boost/components/ExternalLink'
4-
import { setSearchFilter } from 'boost/actions'
4+
import { setSearchFilter, clearSearch } from 'boost/actions'
55

66
export default class ArticleTopBar extends React.Component {
77
isInputFocused () {
88
return document.activeElement === ReactDOM.findDOMNode(this.refs.searchInput)
99
}
1010

11+
escape () {
12+
let { status, dispatch } = this.props
13+
if (status.search.length > 0) {
14+
dispatch(clearSearch())
15+
return
16+
}
17+
this.blurInput()
18+
}
19+
1120
focusInput () {
1221
ReactDOM.findDOMNode(this.refs.searchInput).focus()
1322
}

0 commit comments

Comments
 (0)