Skip to content

🎥 Make videos programmatically with React

really nice combobox behavior

Jonny Burger1b16166cd126
diff --git a/packages/cli/src/editor/components/Menu/MenuSubItem.tsx b/packages/cli/src/editor/components/Menu/MenuSubItem.tsx
index 67b1f99736..d97047b02a 100644
--- a/packages/cli/src/editor/components/Menu/MenuSubItem.tsx
+++ b/packages/cli/src/editor/components/Menu/MenuSubItem.tsx
@@ -132,6 +132,15 @@ export const MenuSubItem: React.FC<{
return () => clearTimeout(hi);
}, [hovered, selected, setSubMenuActivated, subMenu]);
+ useEffect(() => {
+ if (selected) {
+ ref.current?.scrollIntoView({
+ // block is vertical alignment, inline is horizontal alignment. So we use "block"
+ block: 'nearest',
+ });
+ }
+ }, [selected]);
+
return (
<div
ref={ref}
diff --git a/packages/cli/src/editor/components/NewComposition/ComboBox.tsx b/packages/cli/src/editor/components/NewComposition/ComboBox.tsx
index d4bc7418a6..654b7e187f 100644
--- a/packages/cli/src/editor/components/NewComposition/ComboBox.tsx
+++ b/packages/cli/src/editor/components/NewComposition/ComboBox.tsx
@@ -147,8 +147,8 @@ export const Combobox: React.FC<{
};
}, [refresh]);
- // TODO: Scroll to current value if there are a lot of values
// TODO: If long value is selected, layout breaks
+ // TODO: If combobox is inside a scrollable container, it doesn't scroll with it
const portalStyle = useMemo((): React.CSSProperties | null => {
if (!opened || !size) {