Skip to content

Commit 64b1884

Browse files
author
Ives van Hoorne
committed
Open editor when clicking file in embed and editor is not shown
1 parent b34eec1 commit 64b1884

File tree

1 file changed

+17
-1
lines changed
  • packages/app/src/embed/components/App

1 file changed

+17
-1
lines changed

packages/app/src/embed/components/App/index.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,23 @@ export default class App extends React.PureComponent<{}, State> {
137137
this.setState({ showEditor: false, showPreview: true });
138138
setMixedView = () => this.setState({ showEditor: true, showPreview: true });
139139

140-
setCurrentModule = (id: string) => this.setState({ currentModule: id });
140+
setCurrentModule = (id: string) => {
141+
const newState: {
142+
currentModule: string,
143+
showEditor?: boolean,
144+
showPreview?: boolean,
145+
} = { currentModule: id };
146+
147+
if (!this.state.showEditor) {
148+
newState.showEditor = true;
149+
if (this.state.showPreview) {
150+
// Means that the user was only looking at preview, which suggests that the screen is small.
151+
newState.showPreview = false;
152+
}
153+
}
154+
155+
this.setState(newState);
156+
};
141157

142158
toggleSidebar = () => this.setState({ sidebarOpen: !this.state.sidebarOpen });
143159

0 commit comments

Comments
 (0)