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
|
||||
|
||||
render() {
|
||||
|
@ -222,8 +231,7 @@ class Editor extends React.Component {
|
|||
tabIndex="0"
|
||||
ref="optionsButton"
|
||||
onClick={() => {
|
||||
this.refs.optionsButton.focus();
|
||||
this.props.showEditorOptions();
|
||||
this.toggleEditorOptions();
|
||||
}}
|
||||
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) {
|
||||
return (
|
||||
<li key={childId}>
|
||||
|
@ -120,8 +129,7 @@ export class FileNode extends React.Component {
|
|||
ref={`fileOptions-${this.props.id}`}
|
||||
tabIndex="0"
|
||||
onClick={() => {
|
||||
this.refs[`fileOptions-${this.props.id}`].focus();
|
||||
this.props.showFileOptions(this.props.id);
|
||||
this.toggleFileOptions();
|
||||
}}
|
||||
>
|
||||
<InlineSVG src={downArrowUrl} />
|
||||
|
|
|
@ -16,6 +16,15 @@ class Sidebar extends React.Component {
|
|||
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() {
|
||||
const sidebarClass = classNames({
|
||||
sidebar: true,
|
||||
|
@ -39,8 +48,7 @@ class Sidebar extends React.Component {
|
|||
tabIndex="0"
|
||||
ref="sidebarOptions"
|
||||
onClick={() => {
|
||||
this.refs.sidebarOptions.focus();
|
||||
this.props.openProjectOptions();
|
||||
this.toggleProjectOptions();
|
||||
}}
|
||||
onBlur={() => setTimeout(this.props.closeProjectOptions, 200)}
|
||||
>
|
||||
|
|
Loading…
Reference in a new issue