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:
@@ -34,7 +34,7 @@ class HomePage extends React.Component {
|
|||||||
let { nav, top, list, detail } = this.refs
|
let { nav, top, list, detail } = this.refs
|
||||||
|
|
||||||
if (top.isInputFocused() && !e.metaKey) {
|
if (top.isInputFocused() && !e.metaKey) {
|
||||||
if (e.keyCode === 13 || e.keyCode === 27) top.blurInput()
|
if (e.keyCode === 13 || e.keyCode === 27) top.escape()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@ class HomePage extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// `detail`の`openDeleteConfirmMenu`が`true`なら呼ばれない。
|
// `detail`の`openDeleteConfirmMenu`が`true`なら呼ばれない。
|
||||||
if (e.keyCode === 27) {
|
if (e.keyCode === 27 || (e.keyCode === 70 && e.metaKey)) {
|
||||||
top.focusInput()
|
top.focusInput()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ export default class ArticleList extends React.Component {
|
|||||||
clearInterval(this.refreshTimer)
|
clearInterval(this.refreshTimer)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 移動ができなかったらfalseを返す:
|
||||||
selectPriorArticle () {
|
selectPriorArticle () {
|
||||||
let { articles, activeArticle, dispatch } = this.props
|
let { articles, activeArticle, dispatch } = this.props
|
||||||
let targetIndex = articles.indexOf(activeArticle) - 1
|
let targetIndex = articles.indexOf(activeArticle) - 1
|
||||||
@@ -22,7 +23,9 @@ export default class ArticleList extends React.Component {
|
|||||||
|
|
||||||
if (targetArticle != null) {
|
if (targetArticle != null) {
|
||||||
dispatch(switchArticle(targetArticle.key))
|
dispatch(switchArticle(targetArticle.key))
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
selectNextArticle () {
|
selectNextArticle () {
|
||||||
@@ -32,7 +35,9 @@ export default class ArticleList extends React.Component {
|
|||||||
|
|
||||||
if (targetArticle != null) {
|
if (targetArticle != null) {
|
||||||
dispatch(switchArticle(targetArticle.key))
|
dispatch(switchArticle(targetArticle.key))
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
handleArticleClick (article) {
|
handleArticleClick (article) {
|
||||||
|
|||||||
@@ -1,13 +1,22 @@
|
|||||||
import React, { PropTypes } from 'react'
|
import React, { PropTypes } from 'react'
|
||||||
import ReactDOM from 'react-dom'
|
import ReactDOM from 'react-dom'
|
||||||
import ExternalLink from 'boost/components/ExternalLink'
|
import ExternalLink from 'boost/components/ExternalLink'
|
||||||
import { setSearchFilter } from 'boost/actions'
|
import { setSearchFilter, clearSearch } from 'boost/actions'
|
||||||
|
|
||||||
export default class ArticleTopBar extends React.Component {
|
export default class ArticleTopBar extends React.Component {
|
||||||
isInputFocused () {
|
isInputFocused () {
|
||||||
return document.activeElement === ReactDOM.findDOMNode(this.refs.searchInput)
|
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 () {
|
focusInput () {
|
||||||
ReactDOM.findDOMNode(this.refs.searchInput).focus()
|
ReactDOM.findDOMNode(this.refs.searchInput).focus()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user