Skip to content

Commit

Permalink
Merge pull request #194 from Guzzing/hotfix/selectcity
Browse files Browse the repository at this point in the history
hotfix: SelectRef 추가 (이전 스텝으로 이동시 Select 컴포넌트가 초기화 되지 않는 문제)
  • Loading branch information
HeeSeok-kim authored Nov 28, 2023
2 parents dea81bc + b699238 commit 5e5bb1e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/components/selectcity/CityStep.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useMemo } from 'react'
import { useEffect, useMemo, useRef } from 'react'
import Select from '@/components/common/inputbox/select/Select.tsx'
import StepQuestion from '@/components/common/stepquestion/StepQuestion.tsx'
import TextBox from '@/components/common/textBox/TextBox.tsx'
Expand All @@ -13,6 +13,7 @@ const CityStep = ({
selectCity = '',
onClick
}: SelectCityProps) => {
const selectRef = useRef<HTMLSelectElement>(null)
const MainTitle = useMemo(() => {
const {
DEFAULT_TITLE,
Expand Down Expand Up @@ -40,6 +41,12 @@ const CityStep = ({
return [PROVINCE_TEXT, CITY_TEXT, TOWN_TEXT]
}, [])

useEffect(()=>{
if(selectRef.current){
selectRef.current.selectedIndex = 0
}
},[currentStep])

return (
<>
<span className={'headline-30 text-left mt-[60px] ml-[37px] leading-8'}>
Expand Down Expand Up @@ -85,6 +92,7 @@ const CityStep = ({
options={selectList}
placeholder={SelectPlaceHolder[currentStep - 1]}
onChange={(e) => onChange(e.target.value)}
ref={selectRef}
/>
</div>
</div>
Expand Down

0 comments on commit 5e5bb1e

Please sign in to comment.