diff --git a/src/containers/laanc/LaancPlanContainer.js b/src/containers/laanc/LaancPlanContainer.js index 466f57e0..52aa8638 100644 --- a/src/containers/laanc/LaancPlanContainer.js +++ b/src/containers/laanc/LaancPlanContainer.js @@ -88,7 +88,8 @@ export default function LaancPlanContainer({ case 'pilot': case 'arcrft': if (name === 'fltElev' || name === 'bufferZone' || name === 'hpno') { - const newValue = value.replace(/[^0-9]/g, ''); + const newValue = value.replace(/^0+/, '').replace(/\D/g, ''); + setDetailData(prevState => { const arr = [...prevState[arrName]]; const updateData = { diff --git a/src/views/laanc/LaancStep1.js b/src/views/laanc/LaancStep1.js index ac6089c5..cf937f71 100644 --- a/src/views/laanc/LaancStep1.js +++ b/src/views/laanc/LaancStep1.js @@ -58,23 +58,23 @@ export default function LaancStep1({ if (!currentParm) setCenteredModal(mapParam); }, [location]); - // const handleInputClick = () => { - // // Input 요소가 포커스될 때 커서를 맨 뒤로 이동 - // if (fltElevRef.current) { - // const input = fltElevRef.current; + const handleInputClick = type => { + // Input 요소가 포커스될 때 커서를 맨 뒤로 이동 + if (fltElevRef.current && type === 'fltElev') { + const input = fltElevRef.current; - // const inputValue = input.value; - // input.setSelectionRange(inputValue.length - 1, inputValue.length - 1); - // input.focus(); - // } - // if (bufferZoneRef.current) { - // const input = bufferZoneRef.current; + const inputValue = input.value; + input.setSelectionRange(inputValue.length - 1, inputValue.length - 1); + input.focus(); + } + if (bufferZoneRef.current && type === 'bufferZone') { + const input = bufferZoneRef.current; - // const inputValue = input.value; - // input.setSelectionRange(inputValue.length - 1, inputValue.length - 1); - // input.focus(); - // } - // }; + const inputValue = input.value; + input.setSelectionRange(inputValue.length - 1, inputValue.length - 1); + input.focus(); + } + }; return ( <> @@ -262,9 +262,8 @@ export default function LaancStep1({ value }); }} - // innerRef={fltElevRef} // Input 요소에 ref를 연결 - // onClick={handleInputClick} - // innerRef={data} + innerRef={fltElevRef} // Input 요소에 ref를 연결 + onClick={() => handleInputClick('fltElev')} placeholder='100m' /> @@ -289,9 +288,8 @@ export default function LaancStep1({ value }); }} - // innerRef={bufferZoneRef} // Input 요소에 ref를 연결 - // onClick={handleInputClick} - // innerRef={data} + innerRef={bufferZoneRef} // Input 요소에 ref를 연결 + onClick={() => handleInputClick('bufferZone')} placeholder='100m' />