@@ -1900,6 +1900,14 @@ function ClipSegmentConfig(props: {
1900
1900
} ) {
1901
1901
const { setProject, setEditorState, project } = useEditorContext ( ) ;
1902
1902
1903
+ // Local state for the input field
1904
+ const [ inputValue , setInputValue ] = createSignal ( props . segment . timescale . toString ( ) ) ;
1905
+
1906
+ // Update input value when timescale changes externally (e.g., from slider or buttons)
1907
+ createEffect ( ( ) => {
1908
+ setInputValue ( props . segment . timescale . toString ( ) ) ;
1909
+ } ) ;
1910
+
1903
1911
return (
1904
1912
< >
1905
1913
< div class = "flex flex-row justify-between items-center" >
@@ -1961,23 +1969,30 @@ function ClipSegmentConfig(props: {
1961
1969
< div class = "flex items-center gap-1" >
1962
1970
< TextInput
1963
1971
type = "number"
1964
- value = { props . segment . timescale . toFixed ( 2 ) }
1972
+ value = { inputValue ( ) }
1965
1973
onInput = { ( e ) => {
1966
- const value = parseFloat ( e . currentTarget . value ) ;
1967
- if ( ! isNaN ( value ) && value > 0 && value <= 10 ) {
1974
+ const value = e . currentTarget . value ;
1975
+ setInputValue ( value ) ;
1976
+
1977
+ const numValue = parseFloat ( value ) ;
1978
+ if ( ! isNaN ( numValue ) && numValue > 0 && numValue <= 10 ) {
1968
1979
setProject (
1969
1980
"timeline" ,
1970
1981
"segments" ,
1971
1982
props . segmentIndex ,
1972
1983
"timescale" ,
1973
- value
1984
+ numValue
1974
1985
) ;
1975
1986
}
1976
1987
} }
1988
+ onFocus = { ( e ) => {
1989
+ // Select all text on focus for easy replacement
1990
+ e . currentTarget . select ( ) ;
1991
+ } }
1977
1992
onBlur = { ( e ) => {
1978
1993
const value = parseFloat ( e . currentTarget . value ) ;
1979
1994
if ( isNaN ( value ) || value <= 0 ) {
1980
- e . currentTarget . value = props . segment . timescale . toFixed ( 2 ) ;
1995
+ setInputValue ( props . segment . timescale . toFixed ( 2 ) ) ;
1981
1996
} else if ( value > 10 ) {
1982
1997
setProject (
1983
1998
"timeline" ,
@@ -1986,7 +2001,10 @@ function ClipSegmentConfig(props: {
1986
2001
"timescale" ,
1987
2002
10
1988
2003
) ;
1989
- e . currentTarget . value = "10.00" ;
2004
+ setInputValue ( "10.00" ) ;
2005
+ } else {
2006
+ // Format to 2 decimal places on blur
2007
+ setInputValue ( value . toFixed ( 2 ) ) ;
1990
2008
}
1991
2009
} }
1992
2010
class = "w-16 px-2 py-1 text-xs text-center border rounded-md bg-gray-2 text-gray-12"
0 commit comments