🎥 Make videos programmatically with React
fix(studio): fix folder select labels and typeahead
Ayodele Ayoolaf5e84b734d50
diff --git a/packages/studio/src/components/NewComposition/NewComposition.tsx b/packages/studio/src/components/NewComposition/NewComposition.tsxindex 4057463f79..41bd24e5f6 100644--- a/packages/studio/src/components/NewComposition/NewComposition.tsx+++ b/packages/studio/src/components/NewComposition/NewComposition.tsx@@ -86,18 +86,18 @@ const folderLabelTextStyle: React.CSSProperties = {const FolderDropdownLabel: React.FC<{readonly indentation: number;- readonly folderPath: string | null;-}> = ({folderPath, indentation}) => {+ readonly folderName: string | null;+}> = ({folderName, indentation}) => {return (<div style={folderLabelStyle}><Spacing x={indentation * 1.5} />- {folderPath === null ? (+ {folderName === null ? (<div style={folderIconStyle} />) : (<CollapsedFolderIcon color={LIGHT_TEXT} style={folderIconStyle} />)}<Spacing x={1} />- <span style={folderLabelTextStyle}>{folderPath ?? 'None'}</span>+ <span style={folderLabelTextStyle}>{folderName ?? 'None'}</span></div>);};@@ -172,7 +172,7 @@ export const NewCompositionFields: React.FC<{{id: rootFolderId,keyHint: null,- label: <FolderDropdownLabel folderPath={null} indentation={0} />,+ label: <FolderDropdownLabel folderName={null} indentation={0} />,leftItem: values.folder.folderName === null ? <Checkmark /> : null,onClick: () => {setValues((current) => ({@@ -209,7 +209,7 @@ export const NewCompositionFields: React.FC<{keyHint: null,label: (<FolderDropdownLabel- folderPath={folderPath}+ folderName={folder.name}indentation={indentation}/>),@@ -224,7 +224,7 @@ export const NewCompositionFields: React.FC<{},}));},- quickSwitcherLabel: folderPath,+ quickSwitcherLabel: folder.name,subMenu: null,type: 'item',value: id,diff --git a/packages/studio/src/components/NewComposition/menu-typeahead.ts b/packages/studio/src/components/NewComposition/menu-typeahead.tsindex 1a366c3573..7a7de74de3 100644--- a/packages/studio/src/components/NewComposition/menu-typeahead.ts+++ b/packages/studio/src/components/NewComposition/menu-typeahead.ts@@ -9,7 +9,7 @@ const getLabelToMatch = (value: ComboboxValue): string | null => {return value.label;}- return null;+ return value.quickSwitcherLabel;};export const findTypeaheadMenuItem = ({diff --git a/packages/studio/src/test/menu-typeahead.test.ts b/packages/studio/src/test/menu-typeahead.test.tsindex a76bc0cc9b..729ea0c100 100644--- a/packages/studio/src/test/menu-typeahead.test.ts+++ b/packages/studio/src/test/menu-typeahead.test.ts@@ -30,14 +30,25 @@ const values: ComboboxValue[] = [},{type: 'item',- id: 'custom',- label: 'Not used',- value: 'fallback',+ id: 'nested-folder',+ label: null,+ value: 'new-composition-folder-SocialMediaAnnouncements/webmcp',onClick: () => undefined,keyHint: null,leftItem: null,subMenu: null,- quickSwitcherLabel: 'Custom Label',+ quickSwitcherLabel: 'webmcp',+ },+ {+ type: 'item',+ id: 'root-folder',+ label: null,+ value: 'new-composition-root-folder',+ onClick: () => undefined,+ keyHint: null,+ leftItem: null,+ subMenu: null,+ quickSwitcherLabel: 'None',},{type: 'item',@@ -62,9 +73,10 @@ test('skips dividers, section headers, and disabled items', () => {expect(findTypeaheadMenuItem({query: 'ban', values})).toBe(null);});-test('matches only the visible string label (not value or quickSwitcherLabel)', () => {- expect(findTypeaheadMenuItem({query: 'custom', values})).toBe(null);- expect(findTypeaheadMenuItem({query: 'not', values})).toBe('custom');+test('uses the visible string label, falling back for non-string labels', () => {+ expect(findTypeaheadMenuItem({query: 'web', values})).toBe('nested-folder');+ expect(findTypeaheadMenuItem({query: 'social', values})).toBe(null);+ expect(findTypeaheadMenuItem({query: 'n', values})).toBe('root-folder');expect(findTypeaheadMenuItem({query: 'diff', values})).toBe(null);expect(findTypeaheadMenuItem({query: 'vis', values})).toBe('label-vs-value');});