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

feat: input창에서 enter를 누를시에 다음 input창으로 이동 #269

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ const PostWriteCommonForm = ({ onChangeData, data, setData }) => {
setIsShowPriceInput((pre) => !pre);
};

const nextInputFocus = (event) => {
if (event.key === 'Enter') {
event.preventDefault();
event.target.blur();
const form = event.target.form;
const index = Array.prototype.indexOf.call(form, event.target);
form.elements[index + 1].focus();
}
};

return (
<>
<Style.OccurTimeLayout>
Expand All @@ -51,6 +61,7 @@ const PostWriteCommonForm = ({ onChangeData, data, setData }) => {
value={data.title}
onChange={onChangeData}
name="title"
onKeyDown={nextInputFocus}
/>
<Style.ContextBodyTextArea
placeholder="상황을 최대한 상세하게 기록해 주세요&#13;(상황, 시간, 사건 전개과정, 경과상태 등)&#13;&#10;최대 2000자"
Expand Down Expand Up @@ -104,12 +115,7 @@ const PostWriteCommonForm = ({ onChangeData, data, setData }) => {
onChange={handlePrice}
onBlur={toggleShowPriceInput}
onFocus={toggleShowPriceInput}
onKeyDown={(event) => {
if (event.key === 'Enter') {
event.preventDefault();
event.target.blur();
}
}}
onKeyDown={nextInputFocus}
/>
</Style.PriceLayout>

Expand Down