🎥 Make videos programmatically with React
better keyboard navigation
Jonny Burgerba1ba8864633
diff --git a/packages/cli/src/editor/components/NewComposition/CancelButton.tsx b/packages/cli/src/editor/components/NewComposition/CancelButton.tsxindex cd883370b2..ac318a132a 100644--- a/packages/cli/src/editor/components/NewComposition/CancelButton.tsx+++ b/packages/cli/src/editor/components/NewComposition/CancelButton.tsx@@ -1,4 +1,5 @@import React, {SVGProps} from 'react';+import {useZIndex} from '../../state/z-index';const style: React.CSSProperties = {appearance: 'none',@@ -12,13 +13,16 @@ export const CancelButton: React.FC<SVGProps<SVGSVGElement> & {onPress: () => void;}-> = ({onPress, ...props}) => (- <button style={style} type="button" onClick={onPress}>- <svg viewBox="0 0 320 512" {...props}>- <path- fill="currentColor"- d="M207.6 256l107.72-107.72c6.23-6.23 6.23-16.34 0-22.58l-25.03-25.03c-6.23-6.23-16.34-6.23-22.58 0L160 208.4 52.28 100.68c-6.23-6.23-16.34-6.23-22.58 0L4.68 125.7c-6.23 6.23-6.23 16.34 0 22.58L112.4 256 4.68 363.72c-6.23 6.23-6.23 16.34 0 22.58l25.03 25.03c6.23 6.23 16.34 6.23 22.58 0L160 303.6l107.72 107.72c6.23 6.23 16.34 6.23 22.58 0l25.03-25.03c6.23-6.23 6.23-16.34 0-22.58L207.6 256z"- />- </svg>- </button>-);+> = ({onPress, ...props}) => {+ const {tabIndex} = useZIndex();+ return (+ <button tabIndex={tabIndex} style={style} type="button" onClick={onPress}>+ <svg viewBox="0 0 320 512" {...props}>+ <path+ fill="currentColor"+ d="M207.6 256l107.72-107.72c6.23-6.23 6.23-16.34 0-22.58l-25.03-25.03c-6.23-6.23-16.34-6.23-22.58 0L160 208.4 52.28 100.68c-6.23-6.23-16.34-6.23-22.58 0L4.68 125.7c-6.23 6.23-6.23 16.34 0 22.58L112.4 256 4.68 363.72c-6.23 6.23-6.23 16.34 0 22.58l25.03 25.03c6.23 6.23 16.34 6.23 22.58 0L160 303.6l107.72 107.72c6.23 6.23 16.34 6.23 22.58 0l25.03-25.03c6.23-6.23 6.23-16.34 0-22.58L207.6 256z"+ />+ </svg>+ </button>+ );+};diff --git a/packages/cli/src/editor/components/NewComposition/ComboBox.tsx b/packages/cli/src/editor/components/NewComposition/ComboBox.tsxindex 6326bcdf14..03fbfc7d6c 100644--- a/packages/cli/src/editor/components/NewComposition/ComboBox.tsx+++ b/packages/cli/src/editor/components/NewComposition/ComboBox.tsx@@ -3,6 +3,7 @@ import React, {useCallback, useEffect, useMemo, useRef, useState} from 'react';import ReactDOM from 'react-dom';import {BACKGROUND, getBackgroundFromHoverState} from '../../helpers/colors';import {FONT_FAMILY} from '../../helpers/font';+import {HigherZIndex} from '../../state/z-index';import {SUBMENU_CONTAINER_CLASS_NAME} from '../Menu/is-menu-click';import {MenuContent} from './MenuContent';@@ -125,11 +126,16 @@ export const Combobox: React.FC<{</div>{portalStyle? ReactDOM.createPortal(- <div style={outerStyle}>- <div className={SUBMENU_CONTAINER_CLASS_NAME} style={portalStyle}>- <MenuContent values={values} onHide={onHide} />+ <HigherZIndex>+ <div style={outerStyle}>+ <div+ className={SUBMENU_CONTAINER_CLASS_NAME}+ style={portalStyle}+ >+ <MenuContent values={values} onHide={onHide} />+ </div></div>- </div>,+ </HigherZIndex>,portal): null}diff --git a/packages/cli/src/editor/components/NewComposition/CompositionType.tsx b/packages/cli/src/editor/components/NewComposition/CompositionType.tsxindex 5bbf29def5..27034d60ed 100644--- a/packages/cli/src/editor/components/NewComposition/CompositionType.tsx+++ b/packages/cli/src/editor/components/NewComposition/CompositionType.tsx@@ -2,6 +2,7 @@ import React, {useCallback, useEffect, useMemo, useRef, useState} from 'react';import {getBackgroundFromHoverState} from '../../helpers/colors';import {FilmIcon} from '../../icons/film';import {StillIcon} from '../../icons/still';+import {useZIndex} from '../../state/z-index';import {Row, Spacing} from '../layout';const panel: React.CSSProperties = {@@ -23,6 +24,7 @@ const Panel: React.FC<{onSelected: (type: CompType) => void;}> = ({selected, type, onSelected}) => {const ref = useRef<HTMLButtonElement>(null);+ const {tabIndex} = useZIndex();const [hovered, setHovered] = useState(false);useEffect(() => {@@ -56,7 +58,13 @@ const Panel: React.FC<{}, [onSelected, type]);return (- <button ref={ref} type="button" style={style} onClick={onClick}>+ <button+ ref={ref}+ tabIndex={tabIndex}+ type="button"+ style={style}+ onClick={onClick}+ >{type === 'composition' ? (<FilmIcon style={{height: 18, width: 18}} />) : (diff --git a/packages/cli/src/editor/components/NewComposition/RemInput.tsx b/packages/cli/src/editor/components/NewComposition/RemInput.tsxindex 8e95613f43..06ff222634 100644--- a/packages/cli/src/editor/components/NewComposition/RemInput.tsx+++ b/packages/cli/src/editor/components/NewComposition/RemInput.tsx@@ -12,6 +12,7 @@ import {SELECTED_BACKGROUND,} from '../../helpers/colors';import {FONT_FAMILY} from '../../helpers/font';+import {useZIndex} from '../../state/z-index';type Props = React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>,@@ -25,6 +26,7 @@ const RemInputForwardRef: React.ForwardRefRenderFunction<const [isFocused, setIsFocused] = useState(false);const [isHovered, setIsHovered] = useState(false);const inputRef = useRef<HTMLInputElement>(null);+ const {tabIndex} = useZIndex();const style = useMemo(() => {return {@@ -76,7 +78,7 @@ const RemInputForwardRef: React.ForwardRefRenderFunction<};}, [inputRef]);- return <input ref={inputRef} {...props} style={style} />;+ return <input ref={inputRef} tabIndex={tabIndex} {...props} style={style} />;};export const RemotionInput = forwardRef(RemInputForwardRef);