Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.
TypeScript cross-platformelectronffmpegopen-sourceproduct-demorustscreen-capturescreen-recorderscreen-recordingscreen-studioscreencastspeech-to-texttypescriptvideo-editingvideo-editorwaylandwgpuwhisper
fix(topbar): stop the header re-flowing on every state change
Etienne Lescotf2bddc148c17
diff --git a/src/components/ai-edition/v4/EditorShellV4.module.css b/src/components/ai-edition/v4/EditorShellV4.module.cssindex 280408ba6..e3698c75a 100644--- a/src/components/ai-edition/v4/EditorShellV4.module.css+++ b/src/components/ai-edition/v4/EditorShellV4.module.css@@ -24,11 +24,21 @@/* rows set inline per mode (topbar / body / timeline) *//* ─── TOP BAR ──────────────────────────────────────────────────────── */+/* Every slot on the left half is width-STABLE by construction: the chat toggle+ reserves its box even in the modes that don't have one, the project name and+ the save state are fixed-size regardless of the string inside them. Without+ that, hiding a button, renaming a project or simply typing (saved → unsaved)+ re-flowed the whole bar and slid the mode switch sideways. */.topbar {grid-row: 1;display: flex;align-items: center;- gap: 14px;+ gap: var(--topbar-gap);+ --topbar-gap: 14px;+ --topbar-icon: 32px;+ --topbar-project-w: 180px;+ /* Widest of the short locale labels — "PT-BR", and the CJK "简中". */+ --topbar-lang-label-w: 38px;/* The topbar doubles as the window titlebar, so it keeps clear of the nativewindow controls: the macOS traffic lights (--titlebar-inset-left, injectedper-platform by the main process) on the left, and the Windows/Linux Window@@ -56,6 +66,17 @@background: var(--border);flex-shrink: 0;}+/* Reserved box for the chat toggle and its rule. The toggle only exists in Edit+ mode (the left panel doesn't render in Media/Rec), so without a slot holding+ the space every mode change shoved the rest of the bar sideways. Width =+ button + gap + rule, i.e. exactly what it holds when it is there. */+.topbarLead {+ display: inline-flex;+ align-items: center;+ gap: var(--topbar-gap);+ width: calc(var(--topbar-icon) + var(--topbar-gap) + 1px);+ flex-shrink: 0;+}.brand {display: inline-flex;align-items: center;@@ -127,9 +148,24 @@opacity: 0.45;cursor: not-allowed;}+/* The project name keeps one width whatever it is called — and the read view and+ the edit input keep the SAME width, so clicking to rename doesn't nudge the+ bar either. A long title truncates rather than pushing its neighbours. */+.projectNameBtn {+ width: var(--topbar-project-w);+ justify-content: flex-start;+ box-sizing: border-box;+}+.projectNameLabel {+ min-width: 0;+ overflow: hidden;+ text-overflow: ellipsis;+ white-space: nowrap;+}.projectNameInput {height: 30px;- min-width: 160px;+ width: var(--topbar-project-w);+ box-sizing: border-box;padding: 0 10px;border-radius: 9px;border: 1px solid var(--accent);@@ -138,15 +174,33 @@font: 500 13px var(--font-display);outline: none;}+/* Both states are rendered into the SAME grid cell, so the slot is as wide as+ the longer of the two and never resizes when the document goes dirty — which+ happens on every keystroke. Sizing to the longer string beats guessing a width:+ "Saved"/"Unsaved" differ by 2 characters in English and by 4 in French, and a+ hard-coded width would clip somewhere among the 13 locales. */.saved {- display: inline-flex;+ display: inline-grid;+ grid-template-areas: "state";align-items: center;- gap: 6px;+ justify-items: start;font-family: var(--font-mono);font-size: 11px;color: var(--muted);flex-shrink: 0;}+.savedState {+ grid-area: state;+ display: inline-flex;+ align-items: center;+ gap: 6px;+ white-space: nowrap;+}+/* visibility (not display) so the hidden state still contributes its width —+ and stays out of the accessibility tree. */+.savedState[data-on="false"] {+ visibility: hidden;+}.saved .dot {width: 6px;height: 6px;@@ -155,20 +209,44 @@box-shadow: 0 0 0 3px var(--accent-soft);}+/* One box for every short locale label — see --topbar-lang-label-w. Without it+ the language button resized between "EN", "PT-BR" and the CJK "简中", moving+ everything to its right. */+.langShort {+ width: var(--topbar-lang-label-w);+ text-align: center;+ font-family: var(--font-mono);+ font-size: 11px;+ font-weight: 600;+ white-space: nowrap;+}+/* mode switch (Media / Edit / Rec) */+/* Three EQUAL columns, not three content-sized buttons. `1fr` tracks in an+ intrinsically-sized grid all take the width of the widest one, so the trio+ stays symmetrical in every locale — English "Rec" next to "Media", French+ "Enregistrement" next to "Médias" — and the hover/selected plate is the same+ box on all three. */.modeSwitch {margin: 0 auto;- display: inline-flex;+ display: inline-grid;+ grid-template-columns: repeat(3, minmax(0, 1fr));align-items: center;gap: 2px;padding: 3px;background: var(--surface-1);border: 1px solid var(--border);border-radius: 11px;- flex-shrink: 0;+ /* The only shrinkable item in the bar (everything else is flex-shrink: 0), so+ a verbose locale — fr "Enregistrement" is nearly twice "Médias" — narrows+ this control instead of shoving Export off the edge of a 1200px window. The+ columns stay equal to each other while it happens; only the labels clip. */+ flex-shrink: 1;+ min-width: 0;}.modeSwitch button {padding: 5px 14px;+ white-space: nowrap;border: 0;border-radius: 7px;background: transparent;@@ -177,6 +255,32 @@font-weight: 500;cursor: pointer;transition: background var(--motion-fast) var(--ease), color var(--motion-fast) var(--ease);+ /* Label and a hidden BOLD copy of it share one cell. Selecting a tab switches+ the label to 600, which is wider than the 500 it was — enough to resize the+ widest column and shift the whole control. Reserving the bold width up front+ makes each button the same size selected, hovered or idle. */+ display: grid;+ grid-template-areas: "label";+ /* minmax(0,…) so the cell can be narrower than the text: without it the inner+ column sizes to the label and the button just clips it mid-glyph, instead of+ letting the label ellipsise. */+ grid-template-columns: minmax(0, 1fr);+ place-items: center;+ min-width: 0;+ overflow: hidden;+}+.modeSwitch button::before {+ content: attr(data-label);+ grid-area: label;+ font-weight: 600;+ visibility: hidden;+}+.modeLabel {+ grid-area: label;+ max-width: 100%;+ overflow: hidden;+ text-overflow: ellipsis;+ white-space: nowrap;}.modeSwitch button[aria-selected="true"] {background: var(--surface-3);diff --git a/src/components/ai-edition/v4/EditorTopBar.tsx b/src/components/ai-edition/v4/EditorTopBar.tsxindex f91a91be6..abe3ec50a 100644--- a/src/components/ai-edition/v4/EditorTopBar.tsx+++ b/src/components/ai-edition/v4/EditorTopBar.tsx@@ -63,21 +63,25 @@ export function EditorTopBar({const showChatToggle = mode === "edit";return (<header className={styles.topbar}>- {showChatToggle ? (- <>- <button- type="button"- className={`${styles.iconBtn}${chatOpen ? ` ${styles.on}` : ""}`}- title={t("topbar.toggleChatPanel")}- aria-label={t("topbar.toggleChatPanel")}- aria-pressed={chatOpen}- onClick={actions.toggleChat}- >- <PanelLeft size={17} />- </button>- <span className={styles.sep} aria-hidden />- </>- ) : null}+ {/* Fixed-width slot: the toggle is Edit-only, and .topbarLead holds its+ space in the other modes so nothing to the right moves. */}+ <span className={styles.topbarLead}>+ {showChatToggle ? (+ <>+ <button+ type="button"+ className={`${styles.iconBtn}${chatOpen ? ` ${styles.on}` : ""}`}+ title={t("topbar.toggleChatPanel")}+ aria-label={t("topbar.toggleChatPanel")}+ aria-pressed={chatOpen}+ onClick={actions.toggleChat}+ >+ <PanelLeft size={17} />+ </button>+ <span className={styles.sep} aria-hidden />+ </>+ ) : null}+ </span><span className={styles.brand}>{/* Decorative: the wordmark right beside it already names the app. */}<img src={logoMark} alt="" draggable={false} />@@ -130,22 +134,23 @@ export function EditorTopBar({</button><span className={styles.sep} aria-hidden /><LangButton />+ {/* Both states are always rendered, stacked in one grid cell, so the slot+ keeps the width of the longer label and the bar doesn't twitch every+ time the document goes dirty. The inactive one is visibility:hidden,+ which also takes it out of the accessibility tree. */}<span className={styles.saved}>- {dirty ? (- <>- <span- className={styles.dot}- aria-hidden- style={{ background: "var(--warn)", boxShadow: "0 0 0 3px var(--warn-soft)" }}- />- {t("topbar.unsaved")}- </>- ) : (- <>- <span className={styles.dot} aria-hidden />- {t("topbar.saved")}- </>- )}+ <span className={styles.savedState} data-on={!dirty}>+ <span className={styles.dot} aria-hidden />+ {t("topbar.saved")}+ </span>+ <span className={styles.savedState} data-on={dirty}>+ <span+ className={styles.dot}+ aria-hidden+ style={{ background: "var(--warn)", boxShadow: "0 0 0 3px var(--warn-soft)" }}+ />+ {t("topbar.unsaved")}+ </span></span><div className={styles.modeSwitch} role="tablist" aria-label={t("topbar.editorMode")}>@@ -155,9 +160,12 @@ export function EditorTopBar({type="button"role="tab"aria-selected={mode === m.id}+ // Feeds the hidden bold copy that reserves the selected width — see+ // .modeSwitch button::before.+ data-label={t(m.labelKey)}onClick={() => onModeChange(m.id)}>- {t(m.labelKey)}+ <span className={styles.modeLabel}>{t(m.labelKey)}</span></button>))}</div>@@ -241,12 +249,15 @@ function ProjectNameField({return (<buttontype="button"- className={styles.ghostBtn}+ className={`${styles.ghostBtn} ${styles.projectNameBtn}`}aria-label={t("topbar.renameProject")}+ // The label is truncated to keep the slot fixed, so the full name has to+ // stay reachable on hover.+ title={title ?? undefined}disabled={!title}onClick={startEditing}>- {title ?? t("topbar.noProject")}+ <span className={styles.projectNameLabel}>{title ?? t("topbar.noProject")}</span></button>);}@@ -275,9 +286,10 @@ function LangButton() {aria-pressed={open}><Languages size={15} />- <span style={{ fontFamily: "var(--font-mono)", fontSize: 11, fontWeight: 600 }}>- {getLocaleShort(locale)}- </span>+ {/* Fixed-width, centred: the short labels run from "EN" to "PT-BR" to+ the CJK "简中", and letting the button size to them moved everything+ to its right on each language change. */}+ <span className={styles.langShort}>{getLocaleShort(locale)}</span><ChevronDown size={9} style={{ color: "var(--muted)" }} /></button>{open ? (