Skip to content

Commit d43af4d

Browse files
committed
focus on add_new
1 parent 4303959 commit d43af4d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

packages/repl/src/lib/Input/ComponentSelector.svelte

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import RunesInfo from './RunesInfo.svelte';
33
import Migrate from './Migrate.svelte';
44
import type { Workspace, File } from 'editor';
5+
import { tick } from 'svelte';
56
67
interface Props {
78
runes: boolean;
@@ -12,6 +13,7 @@
1213
1314
let { runes, onchange, workspace, can_migrate }: Props = $props();
1415
16+
let input = $state() as HTMLInputElement;
1517
let input_value = $state(workspace.current.name);
1618
1719
async function close_edit(file: File) {
@@ -48,7 +50,7 @@
4850
onchange();
4951
}
5052
51-
function add_new() {
53+
async function add_new() {
5254
const basename = deconflict(`Component.svelte`);
5355
5456
const file = workspace.add({
@@ -61,6 +63,9 @@
6163
6264
input_value = file.name;
6365
onchange();
66+
67+
await tick();
68+
input.focus();
6469
}
6570
6671
// drag and drop
@@ -108,6 +113,7 @@
108113
<!-- svelte-ignore a11y_autofocus -->
109114
<input
110115
spellcheck={false}
116+
bind:this={input}
111117
bind:value={input_value}
112118
onfocus={async (event) => {
113119
const input = event.currentTarget;

0 commit comments

Comments
 (0)