Skip to content

Commit 47e65e3

Browse files
cevhericlaude
andcommitted
fix: re-apply .studio.js on each VT navigation; guard delegated targets; clearer [section] error; drop unused standalone prop
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent cd9d56b commit 47e65e3

5 files changed

Lines changed: 15 additions & 10 deletions

File tree

src/components/studio/Explorer.astro

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ interface Props {
55
active?: string;
66
idPrefix?: string; // to keep ids unique between desktop sidebar & mobile drawer
77
showConnectionsLabel?: boolean;
8-
standalone?: boolean;
98
}
10-
const { active = 'home', idPrefix = 'exp', showConnectionsLabel = true, standalone = false } = Astro.props;
9+
const { active = 'home', idPrefix = 'exp', showConnectionsLabel = true } = Astro.props;
1110
---
1211
<div data-explorer-root class="flex h-full flex-col text-[13px]">
1312
<!-- Connections -->

src/components/studio/MobileTopBar.astro

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
22
import Explorer from './Explorer.astro';
33
4-
interface Props { active?: string; standalone?: boolean; }
5-
const { active = 'home', standalone = false } = Astro.props;
4+
interface Props { active?: string; }
5+
const { active = 'home' } = Astro.props;
66
const DEMO = 'https://app.libredb.org';
77
---
88
<header class="sticky top-0 z-30 flex h-14 items-center justify-between border-b border-edge bg-canvas/95 px-3 backdrop-blur lg:hidden">

src/components/studio/StudioShell.astro

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
// src/components/studio/StudioShell.astro
3-
// The shared IDE chrome. index.astro and deploy.astro both render through this.
3+
// Shared IDE chrome for the home page and every [section] page.
44
import TopBar from './TopBar.astro';
55
import MobileTopBar from './MobileTopBar.astro';
66
import Explorer from './Explorer.astro';
@@ -21,11 +21,11 @@ const { active = 'home', standalone = false } = Astro.props;
2121
data-standalone={standalone ? '' : undefined}
2222
>
2323
<div class="hidden lg:block" transition:persist="topbar"><TopBar /></div>
24-
<MobileTopBar active={active} standalone={standalone} transition:persist="mobiletop" />
24+
<MobileTopBar active={active} transition:persist="mobiletop" />
2525

2626
<div class="studio-workbench flex min-h-0 flex-1">
2727
<aside class="hidden w-64 shrink-0 overflow-y-auto border-r border-edge lg:block" transition:persist="sidebar">
28-
<Explorer active={active} idPrefix="side" standalone={standalone} />
28+
<Explorer active={active} idPrefix="side" />
2929
</aside>
3030

3131
<main class="studio-pane min-w-0 flex-1 lg:flex lg:flex-col">

src/pages/[section].astro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ const COMPONENTS: Record<string, any> = {
3535
const { id } = Astro.props as { id: string };
3636
const meta = sectionById[id];
3737
const Body = COMPONENTS[id];
38+
if (!Body) throw new Error(`[section].astro: no component mapped for section id "${id}"`);
3839
const jsonLd = sectionSeo[id] ?? [];
3940
---
4041
<Layout title={meta.pageTitle} description={meta.pageDescription}>

src/scripts/studio.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,8 @@ function closePalette() {
303303

304304
/* ---- Delegated action click handler ---- */
305305
function onActionClick(e: Event) {
306-
const target = e.target as HTMLElement;
306+
const target = e.target;
307+
if (!(target instanceof Element)) return;
307308

308309
// Chrome delegations: palette-close, drawer open/close, explorer column toggles
309310
if (target.closest('[data-palette-close]')) { e.preventDefault(); closePalette(); return; }
@@ -376,7 +377,8 @@ function wireOnce() {
376377

377378
// Delegated input: explorer search filter + palette input
378379
document.addEventListener('input', (e) => {
379-
const target = e.target as HTMLElement;
380+
const target = e.target;
381+
if (!(target instanceof Element)) return;
380382
const searchInput = target.closest<HTMLInputElement>('[data-explorer-search]');
381383
if (searchInput) { filterExplorer(searchInput); return; }
382384
const paletteInput = target.closest<HTMLInputElement>('[data-palette-input]');
@@ -386,7 +388,9 @@ function wireOnce() {
386388
// Delegated keydown: explorer search Enter-to-jump
387389
document.addEventListener('keydown', (e) => {
388390
if (e.key !== 'Enter') return;
389-
const searchInput = (e.target as HTMLElement).closest<HTMLInputElement>('[data-explorer-search]');
391+
const target = e.target;
392+
if (!(target instanceof Element)) return;
393+
const searchInput = target.closest<HTMLInputElement>('[data-explorer-search]');
390394
if (!searchInput) return;
391395
const scope = searchInput.closest<HTMLElement>('[data-explorer-root]');
392396
if (!scope) return;
@@ -401,6 +405,7 @@ function wireOnce() {
401405
}
402406

403407
function onPage() {
408+
document.querySelector('[data-studio]')?.classList.add('js');
404409
syncActive();
405410
}
406411

0 commit comments

Comments
 (0)