Skip to content

🎥 Make videos programmatically with React

`@remotion/studio`: Fix enum dropdown dismissal (#7981)

Jonny Burgerd147580e27b5
diff --git a/packages/studio/src/state/z-index.tsx b/packages/studio/src/state/z-index.tsx
index 86609ee7fb..545d4fec63 100644
--- a/packages/studio/src/state/z-index.tsx
+++ b/packages/studio/src/state/z-index.tsx
@@ -102,7 +102,10 @@ export const HigherZIndex: React.FC<{
// If a menu is opened, then this component will also still receive the pointerdown event.
// However we may not interpret it as a outside click, so we need to wait for the next tick
requestAnimationFrame(() => {
- window.addEventListener('pointerdown', listener);
+ // The third argument `true` registers a capture-phase listener. Some Studio
+ // elements stop pointerdown propagation while still being outside the menu,
+ // so bubbling listeners would miss those clicks and keep the menu open.
+ window.addEventListener('pointerdown', listener, true);
});
return () => {
if (onUp) {
@@ -112,7 +115,7 @@ export const HigherZIndex: React.FC<{
onUp = null;
- return window.removeEventListener('pointerdown', listener);
+ return window.removeEventListener('pointerdown', listener, true);
};
}, [currentIndex, disabled, highestContext.highestIndex, onOutsideClick]);