Skip to content

Commit 9f82293

Browse files
committed
move to the Output panel when clicking run or auto-run
1 parent d4b9e4d commit 9f82293

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src/Playground.res

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,6 +1116,7 @@ module ControlPanel = {
11161116
~state: CompilerManagerHook.state,
11171117
~dispatch: CompilerManagerHook.action => unit,
11181118
~editorCode: React.ref<string>,
1119+
~setCurrentTab: (tab => tab) => unit,
11191120
) => {
11201121
let children = switch state {
11211122
| Init => React.string("Initializing...")
@@ -1135,12 +1136,17 @@ module ControlPanel = {
11351136
| _ => false
11361137
}
11371138

1139+
let runCode = () => {
1140+
setCurrentTab(_ => Output)
1141+
dispatch(RunCode)
1142+
}
1143+
11381144
let onKeyDown = event => {
11391145
switch (
11401146
event->ReactEvent.Keyboard.metaKey || event->ReactEvent.Keyboard.ctrlKey,
11411147
event->ReactEvent.Keyboard.key,
11421148
) {
1143-
| (true, "e") => dispatch(RunCode)
1149+
| (true, "e") => runCode()
11441150
| _ => ()
11451151
}
11461152
}
@@ -1163,10 +1169,18 @@ module ControlPanel = {
11631169
}
11641170

11651171
<div className="flex flex-row gap-x-2">
1166-
<ToggleButton checked=autoRun onChange={_ => dispatch(ToggleAutoRun)}>
1172+
<ToggleButton
1173+
checked=autoRun
1174+
onChange={_ => {
1175+
switch state {
1176+
| Ready({autoRun: false}) => setCurrentTab(_ => Output)
1177+
| _ => ()
1178+
}
1179+
dispatch(ToggleAutoRun)
1180+
}}>
11671181
{React.string("Auto-run")}
11681182
</ToggleButton>
1169-
<Button onClick={_ => dispatch(RunCode)}> {React.string(runButtonText)} </Button>
1183+
<Button onClick={_ => runCode()}> {React.string(runButtonText)} </Button>
11701184
<Button onClick=onFormatClick> {React.string("Format")} </Button>
11711185
<ShareButton actionIndicatorKey />
11721186
</div>
@@ -1671,6 +1685,7 @@ let make = (~versions: array<string>) => {
16711685
state=compilerState
16721686
dispatch=compilerDispatch
16731687
editorCode
1688+
setCurrentTab
16741689
/>
16751690
<div
16761691
className={`flex ${layout == Column ? "flex-col" : "flex-row"}`}

0 commit comments

Comments
 (0)