From 8446b53ff04b326990ce4c3f590a1843ade4bb00 Mon Sep 17 00:00:00 2001 From: Mohamed Boudra Date: Wed, 25 Nov 2026 13:55:31 +0100 Subject: [PATCH] fix(app): share the settings row label line between row kinds After the rebase, rows that lead somewhere drew their own label line with no room for an accessory. On Devices, the "Recommended" badge made the Relay row 2 px taller than the Tailscale row and moved its hint down 1 px. SettingsRowTitle now draws the label and accessory for inline-control rows and for rows that lead somewhere. The accessory overlaps the row's padding, so a row with a badge or info tip has the same label and hint positions as a row without one. Give the Tailscale on/off journey a 120 s budget. Its loading checks open Devices and the setup four more times, and the journey took 52 to 58 s against the default 60 s. --- .../app/e2e/browser/pair-device-relay.spec.ts | 2 + .../app/src/components/settings/index.tsx | 33 ++++++++-- .../src/components/settings/row-header.tsx | 7 +- .../app/src/components/settings/row-label.tsx | 64 ++++--------------- 4 files changed, 47 insertions(+), 59 deletions(-) diff --git a/packages/app/e2e/browser/pair-device-relay.spec.ts b/packages/app/e2e/browser/pair-device-relay.spec.ts index 5d6c236563..918a5befb7 100644 --- a/packages/app/e2e/browser/pair-device-relay.spec.ts +++ b/packages/app/e2e/browser/pair-device-relay.spec.ts @@ -76,6 +76,8 @@ test("turns Tailscale on and off from Devices, asking first over Tailscale", asy baseURL, }, testInfo) => { test.skip(process.platform !== "linux", "Uses a second IPv4 loopback address"); + // The journey opens Devices or the setup six times, two of them over a slowed connection. + test.setTimeout(120_000); if (!baseURL) throw new Error("Expected the app base URL"); const daemon = await startTailscaleTestDaemon(baseURL); try { diff --git a/packages/app/src/components/settings/index.tsx b/packages/app/src/components/settings/index.tsx index cfd1b16340..e85c4f9b91 100644 --- a/packages/app/src/components/settings/index.tsx +++ b/packages/app/src/components/settings/index.tsx @@ -7,7 +7,7 @@ import { useRef, type ReactNode, } from "react"; -import { View } from "react-native"; +import { Text, View } from "react-native"; import { StyleSheet } from "react-native-unistyles"; import type { SettingsRowProps, @@ -25,8 +25,9 @@ import { DropdownTrigger } from "@/components/ui/dropdown-trigger"; import { useIsCompactFormFactor } from "@/constants/layout"; import { settingsStyles } from "@/styles/settings"; import { ControlSizeProvider } from "@/components/ui/control-size"; +import { ExternalLink, type ExternalLinkProps } from "@/components/ui/external-link"; import { useSettingsRowLayout } from "./row-density"; -import { SettingsRowLabel, type SettingsRowLink } from "./row-label"; +import { SettingsRowTitle } from "./row-label"; export { SettingsRowChildren } from "./row-children"; export { SettingsGroup } from "./headings/settings-group"; export { SettingsSection } from "./headings/settings-section"; @@ -46,7 +47,8 @@ interface AppRowExtras { labelAccessory?: ReactNode; /** An icon before the label, such as the thing the row is about. */ leading?: ReactNode; - link?: SettingsRowLink; + /** A page outside the app that helps with this row, drawn under the hint as "Label ↗". */ + link?: Pick; } interface AppSettingsRowProps extends Omit, AppRowExtras { @@ -68,7 +70,16 @@ export function SettingsCard({ children, testID }: { children: ReactNode; testID ); } -export function SettingsRow({ leading, children, testID, ...text }: AppSettingsRowProps) { +export function SettingsRow({ + label, + leading, + labelAccessory, + hint, + link, + error, + children, + testID, +}: AppSettingsRowProps) { const compact = useIsCompactFormFactor(); const layout = useSettingsRowLayout(); const rowStyle = useMemo(() => [layout.row, compact && styles.compactRow], [compact, layout]); @@ -76,7 +87,18 @@ export function SettingsRow({ leading, children, testID, ...text }: AppSettingsR {leading ? {leading} : null} - + + {typeof hint === "string" ? {hint} : hint} + {link ? ( + + + + ) : null} + {error ? ( + + {error} + + ) : null} {children ? ( @@ -218,6 +240,7 @@ const styles = StyleSheet.create((theme) => ({ // The same leading slot as `SettingsRowHeader`, so icons and labels share rails across row kinds. leading: { marginRight: theme.spacing[3], alignItems: "center", justifyContent: "center" }, label: { flexGrow: 1, flexShrink: 1, flexBasis: 160, marginRight: theme.spacing[3] }, + link: { alignItems: "flex-start", marginTop: theme.spacing[1] }, control: { flexShrink: 1, maxWidth: "100%" }, input: { minWidth: 180 }, })); diff --git a/packages/app/src/components/settings/row-header.tsx b/packages/app/src/components/settings/row-header.tsx index 617a309804..254853b4fe 100644 --- a/packages/app/src/components/settings/row-header.tsx +++ b/packages/app/src/components/settings/row-header.tsx @@ -11,6 +11,7 @@ import { SkeletonPulse, useSkeletonPulse } from "@/components/ui/skeleton"; import { settingsStyles } from "@/styles/settings"; import { ICON_SIZE, type Theme } from "@/styles/theme"; import { useSettingsRowLayout, type SettingsRowLayout } from "./row-density"; +import { SettingsRowTitle } from "./row-label"; const ThemedChevron = withUnistyles(ChevronRight); const ThemedLoadingSpinner = withUnistyles(LoadingSpinner); @@ -114,9 +115,8 @@ export function SettingsRowHeader({ ) : null} - - {label} - {labelAccessory} + + {hintStatus ? ( @@ -256,7 +256,6 @@ const styles = StyleSheet.create((theme) => ({ borderRadius: theme.borderRadius.sm, backgroundColor: theme.colors.surface2, }, - labelRow: { flexDirection: "row", alignItems: "center", gap: theme.spacing[2] }, summary: { flexShrink: 1, color: theme.colors.foregroundMuted, diff --git a/packages/app/src/components/settings/row-label.tsx b/packages/app/src/components/settings/row-label.tsx index ac819f85e7..c00c7c4cb6 100644 --- a/packages/app/src/components/settings/row-label.tsx +++ b/packages/app/src/components/settings/row-label.tsx @@ -1,70 +1,34 @@ import { useMemo, type ReactNode } from "react"; import { Text, View } from "react-native"; import { StyleSheet } from "react-native-unistyles"; -import { ExternalLink, type ExternalLinkProps } from "@/components/ui/external-link"; -import { settingsStyles } from "@/styles/settings"; import { useSettingsRowLayout } from "./row-density"; -export type SettingsRowLink = Pick; - -export interface SettingsRowLabelProps { - label: string; - /** Shown beside the label, such as a badge. */ - labelAccessory?: ReactNode; - /** A string is drawn as the hint line; any other node is drawn as given. */ - hint?: ReactNode; - /** A page outside the app that helps with this row, drawn under the hint as "Label ↗". */ - link?: SettingsRowLink; - error?: string | null; -} - /** - * The text column shared by settings rows with inline controls and collapsible content. + * A row's label line: the label, and beside it an accessory such as a badge or an info tip. Rows + * with inline controls and rows that lead somewhere both draw it, so their labels and hints keep + * the same distances whether or not a row carries an accessory. */ -export function SettingsRowLabel({ - label, - labelAccessory, - hint, - link, - error, -}: SettingsRowLabelProps) { +export function SettingsRowTitle({ label, accessory }: { label: string; accessory?: ReactNode }) { const layout = useSettingsRowLayout(); - const accessoryTitleStyle = useMemo(() => [layout.title, styles.accessoryLabel], [layout]); + const titleStyle = useMemo(() => [layout.title, styles.title], [layout]); + if (!accessory) return {label}; return ( - <> - {labelAccessory ? ( - - {label} - {labelAccessory} - - ) : ( - {label} - )} - {typeof hint === "string" ? {hint} : hint} - {link ? ( - - - - ) : null} - {error ? ( - - {error} - - ) : null} - + + {label} + {accessory} + ); } const styles = StyleSheet.create((theme) => ({ - labelRow: { + line: { flexDirection: "row", flexWrap: "wrap", alignItems: "center", gap: theme.spacing[2], }, - accessoryLabel: { flexShrink: 1, minWidth: 0 }, - // A badge is taller than the label's line. It hangs into the row's padding instead, so the label - // and hint keep the distances of a row without one. + title: { flexShrink: 1, minWidth: 0 }, + // An accessory is taller than the label's line. It hangs into the row's padding instead, so the + // label and hint keep the distances of a row without one. accessory: { marginVertical: -theme.spacing[1] }, - link: { alignItems: "flex-start", marginTop: theme.spacing[1] }, }));