Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5ef3a94

Browse files
committed
focus editor after "Format code" btn clicked
1 parent 1defdc0 commit 5ef3a94

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

‎packages/jsrepl/src/app/repl/[[...slug]]/components/code-editor-header.tsx‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,11 @@ export default function CodeEditorHeader() {
122122
[setReplState, editorRef]
123123
)
124124

125+
const onFormatClick = useCallback(async () => {
126+
await editorRef.current?.getAction('editor.action.formatDocument')?.run()
127+
editorRef.current?.focus()
128+
}, [editorRef])
129+
125130
return (
126131
<header ref={headerRef} className="h-repl-header bg-secondary flex items-stretch">
127132
<ScrollArea scrollHideDelay={0} className="flex-1">
@@ -195,9 +200,7 @@ export default function CodeEditorHeader() {
195200
size="icon-xs"
196201
className="text-muted-foreground"
197202
disabled={isReadOnly}
198-
onClick={() => {
199-
editorRef.current?.getAction('editor.action.formatDocument')?.run()
200-
}}
203+
onClick={onFormatClick}
201204
>
202205
<IconPrettier width={15} height={15} />
203206
</Button>

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /