diff --git a/frontend/components/Layout/Layout.js b/frontend/components/Layout/Layout.js index 91989194..96e7ccac 100644 --- a/frontend/components/Layout/Layout.js +++ b/frontend/components/Layout/Layout.js @@ -4,6 +4,7 @@ import { Link, withRouter } from 'react-router-dom'; import Helmet from 'react-helmet'; import styled from 'styled-components'; import { observer, inject } from 'mobx-react'; +import { observable } from 'mobx'; import _ from 'lodash'; import keydown from 'react-keydown'; import Flex from 'components/Flex'; @@ -42,13 +43,13 @@ type Props = { @observer class Layout extends React.Component { props: Props; - state: { modal?: string }; - state = { modal: undefined }; static defaultProps = { search: true, }; + @observable modal = null; + @keydown(['/', 't']) search() { if (this.props.auth.authenticated) @@ -66,16 +67,16 @@ type Props = { }; @keydown('shift+/') - handleOpenKeyboardShortcuts() { - this.setState({ modal: 'keyboard-shortcuts' }); - } + handleOpenKeyboardShortcuts = () => { + this.modal = 'keyboard-shortcuts'; + }; handleCreateCollection = () => { - this.setState({ modal: 'create-collection' }); + this.modal = 'create-collection'; }; handleCloseModal = () => { - this.setState({ modal: undefined }); + this.modal = null; }; render() { @@ -109,9 +110,9 @@ type Props = { Settings - + Keyboard shortcuts - + API @@ -151,7 +152,7 @@ type Props = { @@ -162,7 +163,7 @@ type Props = { />