Skip to content

Commit f96b781

Browse files
authored
Merge pull request #2528 from heygen-com/fix/studio-flat-row-values-right-aligned
fix(studio): right-align FlatRow's value input in the flat inspector
2 parents 6a1585d + b32f9a3 commit f96b781

4 files changed

Lines changed: 27 additions & 1 deletion

File tree

packages/studio/src/components/editor/propertyPanelFlatPrimitives.test.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,16 @@ describe("FlatRow", () => {
3838
act(() => root.unmount());
3939
});
4040

41+
it("right-aligns the value input — the flat inspector's justify-between row layout leaves a left-aligned value looking stranded at the edge of its own box", () => {
42+
const { host, root } = renderInto(
43+
<FlatRow label="Size" value="72px" tier="explicitCustom" onCommit={vi.fn()} />,
44+
);
45+
const input = host.querySelector("input");
46+
expect(input?.className).toContain("text-right");
47+
expect(input?.className).not.toContain("text-left");
48+
act(() => root.unmount());
49+
});
50+
4151
it("renders the explicitCustom tier with a mint value and a reset button", () => {
4252
const onReset = vi.fn();
4353
const { host, root } = renderInto(

packages/studio/src/components/editor/propertyPanelFlatPrimitives.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export function FlatRow({
5151
value={value}
5252
disabled={disabled}
5353
liveCommit={liveCommit}
54+
align="right"
5455
onCommit={(nextValue) => {
5556
track("metric", label);
5657
onCommit(nextValue);

packages/studio/src/components/editor/propertyPanelInputCoverage.test.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,13 @@ describe("classic property-panel primitive telemetry", () => {
134134
const input = host.querySelector("input");
135135
if (!input) throw new Error("expected metric input");
136136

137+
// Regression guard for CommitField's shared `align` default: the classic
138+
// panel lays out label-then-value inline, where left-aligned reads
139+
// naturally — this must stay left even though the flat inspector's
140+
// FlatRow now opts into `align="right"` for its own justify-between rows.
141+
expect(input.className).toContain("text-left");
142+
expect(input.className).not.toContain("text-right");
143+
137144
act(() => blurInput(input));
138145
expect(trackStudioEvent).not.toHaveBeenCalled();
139146

packages/studio/src/components/editor/propertyPanelPrimitives.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,17 @@ export function CommitField({
99
value,
1010
disabled,
1111
liveCommit,
12+
align = "left",
1213
onCommit,
1314
}: {
1415
value: string;
1516
disabled?: boolean;
1617
liveCommit?: boolean;
18+
/** The legacy panel lays out label-then-value inline (left reads naturally);
19+
* the flat inspector lays out label…value across a `justify-between` row,
20+
* where a left-aligned value looks stranded at the edge of its own
21+
* right-hand box instead of lining up with every other row's value. */
22+
align?: "left" | "right";
1723
onCommit: (nextValue: string) => void;
1824
}) {
1925
const [draft, setDraft] = useState(value);
@@ -92,7 +98,9 @@ export function CommitField({
9298
scheduleCommit(nextDraft);
9399
}}
94100
title={parseNumericToken(value) ? "Scroll or use Arrow keys to adjust" : undefined}
95-
className="min-w-0 w-full bg-transparent text-[11px] font-medium text-neutral-100 outline-none disabled:cursor-not-allowed disabled:text-neutral-600"
101+
className={`min-w-0 w-full bg-transparent text-[11px] font-medium text-neutral-100 outline-none disabled:cursor-not-allowed disabled:text-neutral-600 ${
102+
align === "right" ? "text-right" : "text-left"
103+
}`}
96104
/>
97105
);
98106
}

0 commit comments

Comments
 (0)