Skip to content

Commit

Permalink
refactor(ui-date-time-input): use settimeout instead of window.settim…
Browse files Browse the repository at this point in the history
…eout
  • Loading branch information
matyasf committed Dec 17, 2024
1 parent 69e9d24 commit b52ff30
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/ui-date-time-input/src/DateTimeInput/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ class DateTimeInput extends Component<DateTimeInputProps, DateTimeInputState> {
event.persist()
// timeout is needed here because handleDayClick could be called in the same
// frame, and it updates calendarSelectedDate which is read in here.
window.setTimeout(() => {
setTimeout(() => {
if ((event as React.KeyboardEvent).key === 'Enter') {
// user pressed enter, use the selected value in the calendar
this.updateStateBasedOnDateInput(this.state.calendarSelectedDate, event)
Expand Down Expand Up @@ -355,7 +355,7 @@ class DateTimeInput extends Component<DateTimeInputProps, DateTimeInputState> {
const newDate = newState.iso?.toISOString()
// Timeout is needed here because users might change value in the
// onChange event lister, which might not execute properly
window.setTimeout(() => {
setTimeout(() => {
this.props.onChange?.(e, newDate)
}, 0)
}
Expand All @@ -375,7 +375,7 @@ class DateTimeInput extends Component<DateTimeInputProps, DateTimeInputState> {
// happens on the target before the relatedTarget gets focus.
// The timeout gives it a moment for that to happen
if (typeof this.props.onBlur === 'function') {
window.setTimeout(() => {
setTimeout(() => {
this.props.onBlur?.(e)
}, 0)
}
Expand Down

0 comments on commit b52ff30

Please sign in to comment.