Skip to content

Commit d670cc4

Browse files
authored
[BUGFIX] Fix cursor input going EOL (#77)
1 parent 018bc01 commit d670cc4

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

ui/src/components/forms/InlineMonacoEditor.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ type Props = {
1010
onChange: (value: string) => void;
1111
};
1212

13-
const MIN_EDITOR_LINE = 18;
13+
const MIN_EDITOR_LINE = 16;
1414
const MAX_EDITOR_LINE = 50;
1515

1616
const InlineMonacoEditor = ({ value = '', onChange, dataTestId }: Props) => {

ui/src/components/ui/Input.tsx

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,34 @@
1-
import * as React from "react"
1+
import * as React from 'react';
22

3-
import { cn } from "@/lib/utils"
3+
import { cn } from '@/lib/utils';
4+
import { useEffect, useState } from 'react';
45

5-
export interface InputProps
6-
extends React.InputHTMLAttributes<HTMLInputElement> {}
6+
export interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {}
77

88
const Input = React.forwardRef<HTMLInputElement, InputProps>(
9-
({ className, type, ...props }, ref) => {
9+
({ className, type, value, onChange, ...props }, ref) => {
10+
const [storedValue, setStoredValue] = useState(value);
11+
1012
return (
1113
<input
1214
type={type}
15+
value={storedValue}
16+
onChange={(event) => {
17+
setStoredValue(event.target.value);
18+
if (onChange) {
19+
onChange(event);
20+
}
21+
}}
1322
className={cn(
14-
"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
23+
'flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50',
1524
className
1625
)}
1726
ref={ref}
1827
{...props}
1928
/>
20-
)
29+
);
2130
}
22-
)
23-
Input.displayName = "Input"
31+
);
32+
Input.displayName = 'Input';
2433

25-
export { Input }
34+
export { Input };

0 commit comments

Comments
 (0)