From 8c26c9c6e18fa2061679f30ed05d51d6d2929713 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?sanguu516=28=EB=B0=95=EC=83=81=ED=98=84=29?= Date: Wed, 4 Oct 2023 09:52:03 +0900 Subject: [PATCH] =?UTF-8?q?Laanc=20=EA=B3=A0=EB=8F=84=20=EB=B0=98=EA=B2=BD?= =?UTF-8?q?=20input=20=ED=8F=AC=EC=BB=A4=EC=8A=A4=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/containers/laanc/LaancPlanContainer.js | 3 +- src/views/laanc/LaancStep1.js | 40 ++++++++++------------ 2 files changed, 21 insertions(+), 22 deletions(-) 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' />