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

Enabled auto-switch feature for DOB input on the Patient Registration page #9870

Open
wants to merge 13 commits into
base: develop
Choose a base branch
from
Open
20 changes: 14 additions & 6 deletions src/components/Patient/PatientRegistration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -498,12 +498,15 @@ export default function PatientRegistration(
maxLength={2}
max={31}
min={1}
onChange={(e) =>
onChange={(e) => {
setForm((f) => ({
...f,
date_of_birth: `${form.date_of_birth?.split("-")[0] || ""}-${form.date_of_birth?.split("-")[1] || ""}-${e.target.value}`,
}))
}
}));
if (e.target.value.length === 2) {
document.getElementById("month-input")?.focus();
}
}}
modamaan marked this conversation as resolved.
Show resolved Hide resolved
/>
</div>
<div className="flex-1">
Expand All @@ -512,18 +515,22 @@ export default function PatientRegistration(
<span className="text-red-500">*</span>
</Label>
<Input
id="month-input"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's keep the id bit more specific

Suggested change
id="month-input"
id="dob-month-input"

placeholder="MM"
type="number"
value={form.date_of_birth?.split("-")[1] || ""}
maxLength={2}
max={12}
min={1}
onChange={(e) =>
onChange={(e) => {
setForm((f) => ({
...f,
date_of_birth: `${form.date_of_birth?.split("-")[0] || ""}-${e.target.value}-${form.date_of_birth?.split("-")[2] || ""}`,
}))
}
}));
if (e.target.value.length === 2) {
document.getElementById("year-input")?.focus();
}
}}
modamaan marked this conversation as resolved.
Show resolved Hide resolved
/>
</div>
<div className="flex-1">
Expand All @@ -532,6 +539,7 @@ export default function PatientRegistration(
<span className="text-red-500">*</span>
</Label>
<Input
id="year-input"
type="number"
placeholder="YYYY"
value={form.date_of_birth?.split("-")[0] || ""}
Expand Down
Loading