diff --git a/HDesign/src/components/EditableItem/EditableItem.Input.style.ts b/HDesign/src/components/EditableItem/EditableItem.Input.style.ts index 5b2513230..ba57c0b59 100644 --- a/HDesign/src/components/EditableItem/EditableItem.Input.style.ts +++ b/HDesign/src/components/EditableItem/EditableItem.Input.style.ts @@ -14,9 +14,7 @@ type InputSizeStyleProps = { textSize: TextSize; }; -type InputBaseStyleProps = { - width: string; -}; +type InputBaseStyleProps = {}; type InputStyleProps = InputBaseStyleProps & InputSizeStyleProps; @@ -24,9 +22,9 @@ export const inputWrapperStyle = css({ display: 'inline-block', }); -export const inputStyle = ({theme, textSize, width}: WithTheme) => [ +export const inputStyle = ({theme, textSize}: WithTheme) => [ inputSizeStyle({textSize}), - inputBaseStyle({theme, width}), + inputBaseStyle({theme}), ]; const inputSizeStyle = ({textSize}: InputSizeStyleProps) => { @@ -46,7 +44,7 @@ const inputSizeStyle = ({textSize}: InputSizeStyleProps) => { return [style[textSize]]; }; -const inputBaseStyle = ({theme, width}: WithTheme) => +const inputBaseStyle = ({theme}: WithTheme) => css({ border: 'none', outline: 'none', @@ -57,8 +55,6 @@ const inputBaseStyle = ({theme, width}: WithTheme) => '&:placeholder': { color: theme.colors.darkGray, }, - - width, }); export const editingContainerStyle = css({ diff --git a/HDesign/src/components/EditableItem/EditableItem.Input.tsx b/HDesign/src/components/EditableItem/EditableItem.Input.tsx index 7ba433703..f2f1408e8 100644 --- a/HDesign/src/components/EditableItem/EditableItem.Input.tsx +++ b/HDesign/src/components/EditableItem/EditableItem.Input.tsx @@ -1,5 +1,5 @@ /** @jsxImportSource @emotion/react */ -import {forwardRef, useEffect, useImperativeHandle, useRef} from 'react'; +import {forwardRef, useEffect, useImperativeHandle, useRef, useState} from 'react'; import Flex from '@components/Flex/Flex'; import Text from '@components/Text/Text'; @@ -17,7 +17,7 @@ import {InputProps} from './EditableItem.Input.type'; import useEditableItemInput from './useEditableItemInput'; export const EditableItemInput = forwardRef(function Input( - {isFixed = false, textSize = 'body', value = '', hasError = false, readOnly = false, ...htmlProps}, + {isFixed = false, textSize = 'body', hasError = false, readOnly = false, ...htmlProps}, ref, ) { const {theme} = useTheme(); @@ -28,16 +28,15 @@ export const EditableItemInput = forwardRef(functi useEffect(() => { if (shadowRef.current && inputRef.current) { - // 보이지는 않지만 존재하며 value가 담겨있는 Shadow div의 크기를 기준으로 input의 너비를 설정 inputRef.current.style.width = `${shadowRef.current.offsetWidth}px`; } - }, [value]); + }, [htmlProps.value]); return (
- {value || htmlProps.placeholder} + {htmlProps.value || htmlProps.placeholder}
{isFixed &&
*
}
@@ -45,7 +44,6 @@ export const EditableItemInput = forwardRef(functi css={inputStyle({ theme, textSize, - width: `${shadowRef.current?.offsetWidth}px`, })} ref={inputRef} autoFocus @@ -53,7 +51,6 @@ export const EditableItemInput = forwardRef(functi disabled={readOnly} {...htmlProps} placeholder={htmlProps.placeholder} - value={value} />