Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

github pr url 자동완성 기능 추가 #691

Open
wants to merge 16 commits into
base: dev/FE
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: 전체 입력 삭제 시 prefixValue가 입력되게 하는 기능 추가
상규 authored and 상규 committed Nov 3, 2023
commit ab01cc557af91b1a3407bce3de1b9ae7e0629b54
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ export interface Item {
}

const FocusInput = ({ value, setValue, prefixValue, handleBlur }: Props) => {
//prefix값이 존재할 경우 buffer을 prefix로 초기화
//prefix값이 존재할 경우 buffer 상태를 prefix로 초기화
const [inputBuffer, setInputBuffer] = useState(value || (prefixValue ?? ''));
const [currentIndex, setCurrentIndex] = useState(0);
const [autoCompleteListLength, setAutoCompleteListLength] = useState(0);
@@ -38,7 +38,12 @@ const FocusInput = ({ value, setValue, prefixValue, handleBlur }: Props) => {
const input = e.target.value;

// prefixValue가 무조건 value앞에 접두사로 존재
if (input.slice(0, prefixValue?.length ?? 0) !== prefixValue) return;
if (input.slice(0, prefixValue?.length ?? 0) !== prefixValue) {
setInputBuffer(prefixValue ?? '');
setValue(prefixValue ?? '');

return;
}

setInputBuffer(input);
setValue(input);