fix: apply the first script kind selection in the script editor (#10789)

* fix: apply the first script kind selection in the script editor

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QqKXVsBXynMFtMZ26uvLw7

* docs: record why the kind setter's early return is load-bearing

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QqKXVsBXynMFtMZ26uvLw7

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Ruben Fiszel
2026-08-21 02:15:40 +02:00
committed by GitHub
parent d85050f505
commit 75d0c29586
@@ -1466,13 +1466,22 @@
corresponding action.
</Tooltip>
{/snippet}
<!-- A script with no kind yet runs as an action, so the group is fed 'script'
rather than undefined: the toggle group reports no change out of
undefined, which would swallow the first pick. Two-way so the
highlight can never claim a kind the script does not have. -->
<ToggleButtonGroup
selected={script.kind}
on:selected={({ detail }) => {
template = 'script'
script.kind = detail
initContent(script.language, detail, template)
}}
bind:selected={
() => script.kind ?? 'script',
(kind) => {
// Load-bearing: any write to script.kind echoes back through the
// group, and initContent replaces the editor content outright.
if (kind === (script.kind ?? 'script')) return
template = 'script'
script.kind = kind as Script['kind']
initContent(script.language, script.kind, template)
}
}
>
{#snippet children({ item })}
{#each scriptKindOptions as { value, title, desc, documentationLink, Icon }}