diff --git a/.netlify/state.json b/.netlify/state.json new file mode 100644 index 00000000..94c6f8e1 --- /dev/null +++ b/.netlify/state.json @@ -0,0 +1,3 @@ +{ + "siteId": "be420a16-4ef3-43b1-ac62-35869bdf8679" +} \ No newline at end of file diff --git a/src/Header.js b/src/Header.js index 0a735a05..db5d81aa 100644 --- a/src/Header.js +++ b/src/Header.js @@ -1,10 +1,39 @@ -import React from "react"; +import * as React from "react"; import { connect } from "react-redux"; import * as Utils from "./utils"; import * as Selectors from "./redux/selectors"; import * as Actions from "./redux/actionCreators"; +import Disposable from "./Disposable"; class Header extends React.Component { + constructor(props) { + super(props); + this._disposable = new Disposable(); + this._inputRef = null; + } + + componentDidMount() { + const handler = e => { + // slash + if (e.keyCode === 191) { + if (this._inputRef == null) { + return; + } + if (this._inputRef !== document.activeElement) { + this._inputRef.focus(); + e.preventDefault(); + } + } + }; + window.document.addEventListener("keydown", handler); + this._disposable.add(() => { + window.document.removeEventListener("keydown", handler); + }); + } + + componentWillUnmount() { + this._disposable.dispose(); + } render() { return (