Skip to content

Commit

Permalink
refactor: 태크 키씹힘 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
joarthvr committed Dec 9, 2024
1 parent 7dcbf61 commit e7bdf7e
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/features/gathering/ui/GatheringTagInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,16 @@ export const GatheringTagInput = ({
placeholder = '태그를 입력해주세요',
}: GatheringTagInputProps) => {
const [inputValue, setInputValue] = useState('');
const [isComposing, setIsComposing] = useState(false);

const handleKeyDown = (
e: KeyboardEvent<HTMLInputElement>,
onChange: HandleChangeFunction,
currentValue: string[],
) => {
if ((e.key === 'Enter' || (e.metaKey && e.key === 'Enter')) && inputValue.trim()) {
if (isComposing) return;

if (e.key === 'Enter' && inputValue.trim()) {
e.preventDefault();
if (currentValue.length >= 3) {
return;
Expand Down Expand Up @@ -70,6 +73,12 @@ export const GatheringTagInput = ({
onChange={e => {
setInputValue(e.target.value);
}}
onCompositionEnd={() => {
setIsComposing(false);
}}
onCompositionStart={() => {
setIsComposing(true);
}}
onKeyDown={e => {
handleKeyDown(e, onChange, value || []);
}}
Expand Down

0 comments on commit e7bdf7e

Please sign in to comment.