Repository navigation
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
Contributor
🖼️ VRT baseline 재생성 완료
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
💡 작업 내용
useFormReset으로 추출useFormReset적용 (form속성 변경, 언마운트 처리 통일)onChange가 선택 해제를null로 전달하도록 타입 변경WithForm보완, changeset 문서 작성💡 자세한 설명
form.reset()에 대한 Field 계열 컴포넌트의 반응이 제각각이던 문제를 공통 훅으로 정리했습니다.defaultValue로 복원form속성을 바꿔도 처음 폼의 reset에만 반응useFormResetcontrolRef가 속한 폼(HTMLInputElement.form)에 reset 리스너를 연결하고, 초기화가 끝나면onReset을 호출합니다. DateField에 있던 처리를 그대로 옮겼습니다.setTimeout(0)으로 다음 태스크에서 호출합니다. reset 이벤트는 브라우저가 값을 되돌리기 전에 발생하고, 소비처의 ReactonReset은 폼 요소의 리스너보다 늦게 실행되기 때문입니다. 이 시점이면 native 값이 이미 되돌아가 있고,preventDefault()로 취소됐는지도 확인할 수 있습니다.formprop이 바뀌면 리스너를 새 폼에 다시 연결합니다.onReset은usePreservedCallback으로 감싸 리스너를 렌더마다 다시 붙이지 않습니다.컴포넌트별 적용
useTextLengthCounter안에서 처리합니다. 비제어 모드는 초기화 후 DOM 값으로 글자 수를 다시 셉니다. 제어 모드는 React가 기본값을 현재value와 맞춰 두므로 처리하지 않습니다.defaultValue로 상태를 되돌리고 검색어를 비웁니다. 훅이 기준으로 삼는 검색 입력칸에도form={form}을 넘겨 hidden input과 같은 폼을 보게 했습니다. 이 입력칸은name이 없어 제출값에는 영향이 없습니다.useMultiSelectState가setSelectedValues를 함께 반환하도록 했습니다. 공개 API는 아닙니다.defaultValue라는 점을 각 Field의defaultValue주석에 적었습니다.SelectField
onChange타입 변경SelectField의
value는 이미string | null이고,null은 "선택하지 않은 상태"입니다. 다만 선택을 해제하는 UI가 없어null은 시작 상태로만 존재했고, 내부 훅이onChange로null을 넘기지 않도록 걸러내고 있었습니다.이번에 초기화로
null(선택 없음)로 돌아가는 경로가 생기면서, 걸러내는 처리 때문에 화면은 placeholder로 돌아가도onChange로 값을 추적하는 소비처의 상태는 이전 값에 남는 문제가 생겼습니다. 이를 해소하기 위해onChange가null도 전달하도록 바꿨습니다. 제어 모드에서도 초기화 시onChange(null)이 호출되므로 소비처가 상태를 비울 수 있습니다.string만 받는 핸들러를 넘기던 코드는 타입 에러가 나므로 changeset은minor로 작성했습니다.같은 내부 훅(
useSingleSelectState)을 쓰는Select는 선택을 해제하는 경로가 없으므로 공개 타입((value: string) => void)을 유지하고, 컴포넌트 안에서만null을 걸러냅니다.초기화 시
onChange동작onChangedefaultValue로 호출 (기존 동작)""defaultValue로 호출 (기존 동작)nulldefaultValue로 호출, 없으면nullnulldefaultValue로 호출[]초기화 기준은 마운트 시점에 넘긴
defaultValue이며, 이후defaultValueprop을 바꿔도 반영하지 않습니다. 제어 모드는defaultValue를 받지 않으므로 각 컴포넌트의 빈 값으로 초기화합니다.TextField, Textarea의
onChange는 값이 아니라 native change 이벤트를 전달하는 형태이고, 초기화에는 change 이벤트가 없으므로 native<input>처럼 호출하지 않습니다.스토리북
WithForm을 추가했습니다.WithForm에는 초기화 버튼을 추가했고, MultiSelectField와 SuggestionField에는 Counter를 함께 표시합니다.WithForm의defaultValue를 실제File로 바꿨습니다. 다른 파일을 고른 뒤 초기화하고 제출했을 때 기본 파일이 다시 전송되는지로input.files동기화를 확인할 수 있습니다.📗 참고 자료 (선택)
📢 리뷰 요구 사항 (선택)
✅ 셀프 체크리스트
closes #807