Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

184
Views
MUI v5 Date Pickers - Only trigger OnChange during day change?

In the date picker documentation, it requires onChange handler, and has optional onYearChange and onMonthChange handlers but does not have an onDayChange handler. Is there a way to only trigger a date change when only the day changes?

I've tried storing the old date and comparing to the new one onChange to see if the day changed, but changing the year and/or month adjusts the date as well since it triggers onChange.

import React, { useState } from 'react';
import TextField from '@mui/material/TextField';
import AdapterDateFns from '@mui/lab/AdapterDateFns';
import LocalizationProvider from '@mui/lab/LocalizationProvider';
import DatePicker from '@mui/lab/DatePicker';

function DatePickerComponent() {
  const defaultMinDate = new Date('1900-01-01T17:00:00');
  const [value, setValue] = useState(new Date());

  return (
    <LocalizationProvider dateAdapter={AdapterDateFns}>
      <DatePicker
        label="Filter By Date (start)"
        openTo="year"
        views={['year', 'month', 'day']}
        minDate={defaultMinDate}
        value={value}
        onChange={(newValue) => {
          setValue(newValue);
        }}
        renderInput={(params) => <TextField {...params} variant="standard" />}
      />
    </LocalizationProvider>
  );
}

export default DatePickerComponent;

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!