toggling menu (#258)
* toggling menu * Other components should be treated equally
This commit is contained in:
parent
d0445a624d
commit
843418e195
3 changed files with 30 additions and 6 deletions
|
@ -177,6 +177,15 @@ class Editor extends React.Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
toggleEditorOptions() {
|
||||||
|
if (this.props.editorOptionsVisible) {
|
||||||
|
this.props.closeEditorOptions();
|
||||||
|
} else {
|
||||||
|
this.refs.optionsButton.focus();
|
||||||
|
this.props.showEditorOptions();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_cm: CodeMirror.Editor
|
_cm: CodeMirror.Editor
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
@ -222,8 +231,7 @@ class Editor extends React.Component {
|
||||||
tabIndex="0"
|
tabIndex="0"
|
||||||
ref="optionsButton"
|
ref="optionsButton"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
this.refs.optionsButton.focus();
|
this.toggleEditorOptions();
|
||||||
this.props.showEditorOptions();
|
|
||||||
}}
|
}}
|
||||||
onBlur={() => setTimeout(this.props.closeEditorOptions, 200)}
|
onBlur={() => setTimeout(this.props.closeEditorOptions, 200)}
|
||||||
>
|
>
|
||||||
|
|
|
@ -48,6 +48,15 @@ export class FileNode extends React.Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
toggleFileOptions() {
|
||||||
|
if (this.props.isOptionsOpen) {
|
||||||
|
this.props.hideFileOptions(this.props.id);
|
||||||
|
} else {
|
||||||
|
this.refs[`fileOptions-${this.props.id}`].focus();
|
||||||
|
this.props.showFileOptions(this.props.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
renderChild(childId) {
|
renderChild(childId) {
|
||||||
return (
|
return (
|
||||||
<li key={childId}>
|
<li key={childId}>
|
||||||
|
@ -120,8 +129,7 @@ export class FileNode extends React.Component {
|
||||||
ref={`fileOptions-${this.props.id}`}
|
ref={`fileOptions-${this.props.id}`}
|
||||||
tabIndex="0"
|
tabIndex="0"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
this.refs[`fileOptions-${this.props.id}`].focus();
|
this.toggleFileOptions();
|
||||||
this.props.showFileOptions(this.props.id);
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<InlineSVG src={downArrowUrl} />
|
<InlineSVG src={downArrowUrl} />
|
||||||
|
|
|
@ -16,6 +16,15 @@ class Sidebar extends React.Component {
|
||||||
this.props.setSelectedFile(this.props.files[1].id);
|
this.props.setSelectedFile(this.props.files[1].id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
toggleProjectOptions() {
|
||||||
|
if (this.props.projectOptionsVisible) {
|
||||||
|
this.props.closeProjectOptions();
|
||||||
|
} else {
|
||||||
|
this.refs.sidebarOptions.focus();
|
||||||
|
this.props.openProjectOptions();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const sidebarClass = classNames({
|
const sidebarClass = classNames({
|
||||||
sidebar: true,
|
sidebar: true,
|
||||||
|
@ -39,8 +48,7 @@ class Sidebar extends React.Component {
|
||||||
tabIndex="0"
|
tabIndex="0"
|
||||||
ref="sidebarOptions"
|
ref="sidebarOptions"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
this.refs.sidebarOptions.focus();
|
this.toggleProjectOptions();
|
||||||
this.props.openProjectOptions();
|
|
||||||
}}
|
}}
|
||||||
onBlur={() => setTimeout(this.props.closeProjectOptions, 200)}
|
onBlur={() => setTimeout(this.props.closeProjectOptions, 200)}
|
||||||
>
|
>
|
||||||
|
|
Loading…
Reference in a new issue