Skip to content

🎥 Make videos programmatically with React

Fix computed values overlapping Studio inspector

Igor Samokhovets7ee053c3e54a
diff --git a/packages/example/e2e/inspector-control-layout.test.mts b/packages/example/e2e/inspector-control-layout.test.mts
index 77e988dad1..e43f273c08 100644
--- a/packages/example/e2e/inspector-control-layout.test.mts
+++ b/packages/example/e2e/inspector-control-layout.test.mts
@@ -2,6 +2,9 @@ import {expect, type Locator, test} from '@playwright/test';
import {EXPANDED_SIDEBAR_STATE, STUDIO_URL} from './constants.mts';
import {startStudio, stopStudio} from './studio-server.mts';
+const LONG_FONT_FAMILY =
+ "-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Fira Sans', 'Droid Sans', 'Helvetica Neue', Arial, sans-serif";
+
test.use({storageState: EXPANDED_SIDEBAR_STATE});
const getBox = async (locator: Locator) => {
@@ -146,5 +149,28 @@ test.describe('Inspector control layout', () => {
keyframeButton,
colorButton,
);
+
+ const interactiveDiv = page
+ .getByText('Computed font family', {exact: true})
+ .first();
+ const fontFamilyLabel = page.getByText('Font family', {exact: true});
+ await expect(async () => {
+ await interactiveDiv.click();
+ await expect(fontFamilyLabel).toBeVisible({timeout: 1_000});
+ }).toPass({timeout: 30_000});
+
+ const computedFontFamily = page.getByText(LONG_FONT_FAMILY, {exact: true});
+ const computedFontFamilyTooltip = page.getByTitle(LONG_FONT_FAMILY);
+ await computedFontFamilyTooltip.hover();
+ await expect(computedFontFamilyTooltip).toContainText(LONG_FONT_FAMILY);
+ const fontSize = page.getByText('Font size', {exact: true});
+ const [computedFontFamilyBox, fontSizeBox] = await Promise.all([
+ getBox(computedFontFamily),
+ getBox(fontSize),
+ ]);
+ expect(computedFontFamilyBox.height).toBeLessThanOrEqual(18);
+ expect(
+ computedFontFamilyBox.y + computedFontFamilyBox.height,
+ ).toBeLessThanOrEqual(fontSizeBox.y);
});
});
diff --git a/packages/example/src/InspectorControlLayoutE2e.tsx b/packages/example/src/InspectorControlLayoutE2e.tsx
index 4281fb4f1f..35545011c2 100644
--- a/packages/example/src/InspectorControlLayoutE2e.tsx
+++ b/packages/example/src/InspectorControlLayoutE2e.tsx
@@ -53,6 +53,13 @@ const inspectorControlLayoutSchema = {
},
} as const satisfies InteractivitySchema;
+// Passing identifiers instead of inline literals keeps these values computed
+// so the fixture exercises runtime-only values in the Inspector.
+const COMPUTED_FONT_FAMILY =
+ "-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Fira Sans', 'Droid Sans', 'Helvetica Neue', Arial, sans-serif";
+const COMPUTED_TEXT =
+ 'This is an intentionally long computed text value for verifying that runtime-only text is truncated to one line in narrow Inspector panels without overlapping the controls below it.';
+
type InspectorControlLayoutProps = {
readonly name: string;
readonly src: string;
@@ -84,14 +91,22 @@ const InteractiveInspectorControlLayout = Interactive.withSchema({
export const InspectorControlLayoutE2e: React.FC = () => {
return (
- <InteractiveInspectorControlLayout
- name="Inspector control layout"
- src={staticFile('tablet.mp4')}
- first={[-0.1276, 51.5072]}
- second={[139.6917, 35.6895]}
- label="London"
- color="#ff5c4d"
- width={24}
- />
+ <>
+ <InteractiveInspectorControlLayout
+ name="Inspector control layout"
+ src={staticFile('tablet.mp4')}
+ first={[-0.1276, 51.5072]}
+ second={[139.6917, 35.6895]}
+ label="London"
+ color="#ff5c4d"
+ width={24}
+ />
+ <Interactive.Div
+ name="Computed font family"
+ style={{fontFamily: COMPUTED_FONT_FAMILY}}
+ >
+ {COMPUTED_TEXT}
+ </Interactive.Div>
+ </>
);
};
diff --git a/packages/studio/src/components/Timeline/TimelineSchemaField.tsx b/packages/studio/src/components/Timeline/TimelineSchemaField.tsx
index 9b4a131ba9..74d1584858 100644
--- a/packages/studio/src/components/Timeline/TimelineSchemaField.tsx
+++ b/packages/studio/src/components/Timeline/TimelineSchemaField.tsx
@@ -34,6 +34,8 @@ const unsupportedStatusWrapper: React.CSSProperties = {
alignItems: 'center',
display: 'inline-flex',
gap: 4,
+ maxWidth: '100%',
+ minWidth: 0,
userSelect: 'none',
WebkitUserSelect: 'none',
};
@@ -51,7 +53,11 @@ const computedValue: React.CSSProperties = {
fontFamily: 'Arial, Helvetica, sans-serif',
fontSize: 12,
lineHeight: '18px',
+ minWidth: 0,
+ overflow: 'hidden',
pointerEvents: 'none',
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
};
const fixLinkBase: React.CSSProperties = {
@@ -62,6 +68,7 @@ const fixLinkBase: React.CSSProperties = {
hoverColor: WHITE,
}),
display: 'inline-block',
+ flexShrink: 0,
fontSize: 10,
fontStyle: 'normal',
fontWeight: 600,
@@ -109,6 +116,7 @@ export const UnsupportedStatus: React.FC<{
style={unsupportedStatusWrapper}
onPointerEnter={() => setHovered(true)}
onPointerLeave={() => setHovered(false)}
+ title={formattedValue && typeof label === 'string' ? label : undefined}
>
<span
style={formattedValue ? computedValue : unsupportedLabel}