From 60e551e2733dc3557fefc531376fcd8add91a7b0 Mon Sep 17 00:00:00 2001 From: Rokt33r Date: Sat, 31 Oct 2015 18:29:45 +0900 Subject: [PATCH] =?UTF-8?q?Key=E5=85=A5=E5=8A=9B=E3=81=AE=E5=8B=95?= =?UTF-8?q?=E3=81=8D=E6=94=B9=E5=96=84=20-=20Search=E3=81=AB=E5=86=85?= =?UTF-8?q?=E5=AE=B9=E3=81=8C=E3=81=82=E3=82=8B=E6=99=82=E3=81=ABEsc?= =?UTF-8?q?=E3=82=92=E6=8A=BC=E3=81=99=E3=81=A8=E5=86=85=E5=AE=B9=E3=82=92?= =?UTF-8?q?Search=E3=81=AE=E5=86=85=E5=AE=B9=E3=82=92=E5=89=8A=E9=99=A4?= =?UTF-8?q?=E3=81=99=E3=82=8B=20-=20Cmd=20+=20F=E3=82=92=E6=8A=BC=E3=81=99?= =?UTF-8?q?=E3=81=A8Search=20input=E3=81=8Cfocus=E3=81=95=E3=82=8C?= =?UTF-8?q?=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- browser/main/HomePage.js | 4 ++-- browser/main/HomePage/ArticleList.js | 5 +++++ browser/main/HomePage/ArticleTopBar.js | 11 ++++++++++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/browser/main/HomePage.js b/browser/main/HomePage.js index 4ed0f81b..3f1ba34d 100644 --- a/browser/main/HomePage.js +++ b/browser/main/HomePage.js @@ -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() } diff --git a/browser/main/HomePage/ArticleList.js b/browser/main/HomePage/ArticleList.js index 3fc307b8..cc81423e 100644 --- a/browser/main/HomePage/ArticleList.js +++ b/browser/main/HomePage/ArticleList.js @@ -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) { diff --git a/browser/main/HomePage/ArticleTopBar.js b/browser/main/HomePage/ArticleTopBar.js index c78ecf37..bd0eae1c 100644 --- a/browser/main/HomePage/ArticleTopBar.js +++ b/browser/main/HomePage/ArticleTopBar.js @@ -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() }