diff --git a/web/sections/LayoutPanel.tsx b/web/sections/LayoutPanel.tsx index 896216e..563c336 100644 --- a/web/sections/LayoutPanel.tsx +++ b/web/sections/LayoutPanel.tsx @@ -1,5 +1,5 @@ import { useCallback, useEffect, useRef, useState } from 'react'; -import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs'; +import { Tabs, TabsList, TabsTrigger } from '@/components/ui/tabs'; import { useClient } from 'hooks/useClient'; import { readableError } from '../errors'; import { useFlash } from '../useFlash'; @@ -114,6 +114,8 @@ export const LayoutPanel = () => { const [draft, setDraft] = useState(null); const [busy, setBusy] = useState(false); const devPort = useDevPort(); + /** Controlled, because the grid stack below decides visibility rather than Radix unmounting. */ + const [tab, setTab] = useState('colours'); const [error, setError] = useState(null); const [saved, flashSaved] = useFlash(); @@ -233,7 +235,7 @@ export const LayoutPanel = () => { enough that it does not need capping, which is the other thing this bought. */} {mode === 'edit' && ( - + Colours @@ -243,8 +245,25 @@ export const LayoutPanel = () => { - - <> + {/* + EVERY panel in the same grid cell, so the block is as tall as the TALLEST of them and stops + moving when the tab changes. + + Measuring the panels and setting a height would need a ResizeObserver, a re-measure on every + edit, and a wrong answer for one frame after each. `grid-area: 1/1` gets it from the layout + engine for nothing, and it stays right when a tab is added or one of them grows a row — + which is the case that made the first fix insufficient. + + `invisible` and not `hidden`: an invisible element still takes its space, which IS the + mechanism. It is also removed from the tab order, so the controls behind the front panel + cannot be reached by keyboard. + */} +
+
+<>
{COLOURS.map(({ key, label, fallback }) => (
@@ -274,10 +293,13 @@ export const LayoutPanel = () => { ))}
- +
- - <> +
+<> {/* Four across, one row. @@ -317,7 +339,8 @@ export const LayoutPanel = () => { ))}
-
+
+
)}