Skip to content

Commit fd01f84

Browse files
committed
update input
1 parent 0754155 commit fd01f84

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/components/field/field-name-content.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ import { ellipsisTruncation } from '@/styles/styles';
55
import { DEFAULT_FIELD_HEIGHT } from '@/utilities/constants';
66

77
const InnerFieldName = styled.div`
8+
width: 100%;
9+
min-height: ${DEFAULT_FIELD_HEIGHT}px;
810
${ellipsisTruncation}
911
`;
1012

11-
const InlineTextarea = styled.textarea`
13+
const InlineInput = styled.input`
1214
border: none;
1315
background: none;
1416
height: ${DEFAULT_FIELD_HEIGHT}px;
@@ -28,7 +30,7 @@ interface FieldNameProps {
2830
export const FieldNameContent = ({ name, isEditable, onChange }: FieldNameProps) => {
2931
const [isEditing, setIsEditing] = useState(false);
3032
const [value, setValue] = useState(name);
31-
const textareaRef = useRef<HTMLTextAreaElement>(null);
33+
const textInputRef = useRef<HTMLInputElement>(null);
3234

3335
const handleSubmit = useCallback(() => {
3436
setIsEditing(false);
@@ -38,15 +40,16 @@ export const FieldNameContent = ({ name, isEditable, onChange }: FieldNameProps)
3840
useEffect(() => {
3941
if (isEditing) {
4042
setTimeout(() => {
41-
textareaRef.current?.focus();
42-
textareaRef.current?.select();
43+
textInputRef.current?.focus();
44+
textInputRef.current?.select();
4345
});
4446
}
4547
}, [isEditing]);
4648

4749
return isEditing ? (
48-
<InlineTextarea
49-
ref={textareaRef}
50+
<InlineInput
51+
type="text"
52+
ref={textInputRef}
5053
value={value}
5154
onChange={e => {
5255
setValue(e.target.value);

0 commit comments

Comments
 (0)