1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 17:56:25 +00:00

Key入力の動き改善

- Searchに内容がある時にEscを押すと内容をSearchの内容を削除する
- Cmd + Fを押すとSearch inputがfocusされる
This commit is contained in:
Rokt33r
2015-10-31 18:29:45 +09:00
parent 954e148be3
commit 60e551e273
3 changed files with 17 additions and 3 deletions

View File

@@ -34,7 +34,7 @@ class HomePage extends React.Component {
let { nav, top, list, detail } = this.refs
if (top.isInputFocused() && !e.metaKey) {
if (e.keyCode === 13 || e.keyCode === 27) top.blurInput()
if (e.keyCode === 13 || e.keyCode === 27) top.escape()
return
}
@@ -68,7 +68,7 @@ class HomePage extends React.Component {
}
// `detail`の`openDeleteConfirmMenu`が`true`なら呼ばれない。
if (e.keyCode === 27) {
if (e.keyCode === 27 || (e.keyCode === 70 && e.metaKey)) {
top.focusInput()
}

View File

@@ -15,6 +15,7 @@ export default class ArticleList extends React.Component {
clearInterval(this.refreshTimer)
}
// 移動ができなかったらfalseを返す:
selectPriorArticle () {
let { articles, activeArticle, dispatch } = this.props
let targetIndex = articles.indexOf(activeArticle) - 1
@@ -22,7 +23,9 @@ export default class ArticleList extends React.Component {
if (targetArticle != null) {
dispatch(switchArticle(targetArticle.key))
return true
}
return false
}
selectNextArticle () {
@@ -32,7 +35,9 @@ export default class ArticleList extends React.Component {
if (targetArticle != null) {
dispatch(switchArticle(targetArticle.key))
return true
}
return false
}
handleArticleClick (article) {

View File

@@ -1,13 +1,22 @@
import React, { PropTypes } from 'react'
import ReactDOM from 'react-dom'
import ExternalLink from 'boost/components/ExternalLink'
import { setSearchFilter } from 'boost/actions'
import { setSearchFilter, clearSearch } from 'boost/actions'
export default class ArticleTopBar extends React.Component {
isInputFocused () {
return document.activeElement === ReactDOM.findDOMNode(this.refs.searchInput)
}
escape () {
let { status, dispatch } = this.props
if (status.search.length > 0) {
dispatch(clearSearch())
return
}
this.blurInput()
}
focusInput () {
ReactDOM.findDOMNode(this.refs.searchInput).focus()
}