Skip to content

🎥 Make videos programmatically with React

select on click

Jonny Burgere5e9f92038b4
diff --git a/packages/cli/src/editor/components/NewComposition/InputDragger.tsx b/packages/cli/src/editor/components/NewComposition/InputDragger.tsx
index b7dcc865e7..c7131167c5 100644
--- a/packages/cli/src/editor/components/NewComposition/InputDragger.tsx
+++ b/packages/cli/src/editor/components/NewComposition/InputDragger.tsx
@@ -3,7 +3,9 @@ import React, {
MouseEventHandler,
PointerEventHandler,
useCallback,
+ useEffect,
useMemo,
+ useRef,
useState,
} from 'react';
import {interpolate} from 'remotion';
@@ -16,6 +18,7 @@ type Props = InputHTMLAttributes<HTMLInputElement> & {
export const InputDragger: React.FC<Props> = ({onValueChange, ...props}) => {
const [inputFallback, setInputFallback] = useState(false);
+ const fallbackRef = useRef<HTMLInputElement>(null);
const style = useMemo(() => {
return {
@@ -102,9 +105,16 @@ export const InputDragger: React.FC<Props> = ({onValueChange, ...props}) => {
[onValueChange, props.min, props.step, props.value]
);
+ useEffect(() => {
+ if (inputFallback) {
+ fallbackRef.current?.select();
+ }
+ }, [inputFallback]);
+
if (inputFallback) {
return (
<RemotionInput
+ ref={fallbackRef}
autoFocus
onKeyPress={onKeyPress}
onBlur={onBlur}