Skip to content

Commit

Permalink
Add auto focus on react-datepicker input field
Browse files Browse the repository at this point in the history
  • Loading branch information
snoesberger committed Dec 6, 2024
1 parent 27ff91f commit d01b7cc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
3 changes: 1 addition & 2 deletions src/components/shared/TableFilters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,7 @@ const FilterSwitch = ({
<div>
<DatePicker
startOpen
showIcon
icon="fa fa-calendar"
autoFocus
selected={startDate}
onChange={(dates) => handleDate(dates)}
startDate={startDate}
Expand Down
12 changes: 4 additions & 8 deletions src/components/shared/wizard/RenderField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,15 +181,13 @@ const EditableDateValue = ({
}) => editMode ? (
<div>
<DatePicker
showIcon
autoFocus
selected={typeof field.value === "string" ? parseISO(field.value) : field.value}
onChange={(value) => setFieldValue(field.name, value)}
onClickOutside={() => setEditMode(false)}
onBlur={() => setEditMode(false)}
showTimeInput
dateFormat="Pp"
startOpen
popperPlacement="bottom"
popperPlacement="bottom-start"
popperClassName="datepicker-custom"
className="datepicker-custom-input"
wrapperClassName="datepicker-custom-wrapper"
Expand Down Expand Up @@ -386,16 +384,14 @@ const EditableSingleValueTime = ({
return editMode ? (
<div>
<DatePicker
showIcon
autoFocus
selected={typeof field.value === "string" ? parseISO(field.value) : field.value}
onChange={(value) => setFieldValue(field.name, value)}
onClickOutside={() => setEditMode(false)}
onBlur={() => setEditMode(false)}
showTimeSelect
showTimeSelectOnly
dateFormat="p"
startOpen
popperPlacement="bottom"
popperPlacement="bottom-start"
popperClassName="datepicker-custom"
className="datepicker-custom-input"
wrapperClassName="datepicker-custom-wrapper"
Expand Down

0 comments on commit d01b7cc

Please sign in to comment.