Description
Steps to reproduce
Steps:
- clone the
mui-x
repo (this repo) - run
pnpm i
- replace file
/packages/x-date-pickers/node_modules/dayjs/dayjs.min.js
with the attached filedayjs.min.js.txt
(remove the.txt
extension). The attached file extends the dayjs parseLocale()method with a
console.log('dayjs.parseLocale invoked');` call. - run
pnpm start
- browse to http://localhost:3001/x/react-date-pickers/date-picker/ with Chrome Dev tools open
- observe ~20.000 console log entries:
dayjs.parseLocale invoked
Modified dayjs.min.js.txt:
Current behavior
The documentation page (http://localhost:3001/x/react-date-pickers/date-picker/) will invoke the dayjs.locale()
(internally named parseLocale
in dayjs) method some 20.000 times upon initial page load.
Selecting dates in the picker increases the amount of calls quickly.
Expected behavior
Fewer calls to dayjs.locale()
.
Context
I stumbled upon this when debugging why the given i18n locale from ThemeProvider
was ignored in only parts of the date picker "Mobile" view: the date and day name in the picker header was not translated, but the months list and action buttons were.
Your environment
npx @mui/envinfo
System:
OS: Windows 10 10.0.19045
Binaries:
Node: 22.16.0 - C:\Program Files\nodejs\node.EXE
npm: 10.9.2 - C:\Program Files\nodejs\npm.CMD
pnpm: 10.12.1 - ~\AppData\Roaming\npm\pnpm.CMD
Browsers:
Chrome: 137.0.7151.104
Edge: Chromium (137.0.3296.83)
npmPackages:
@emotion/react: catalog: => 11.14.0
@emotion/styled: catalog: => 11.14.0
@mui/icons-material: catalog: => 7.1.1
@mui/internal-babel-plugin-display-name: ^1.0.1 => 1.0.1
@mui/internal-babel-plugin-resolve-imports: ^2.0.4 => 2.0.4
@mui/internal-bundle-size-checker: ^1.0.5 => 1.0.5
@mui/internal-markdown: ^2.0.6 => 2.0.6
@mui/internal-test-utils: catalog: => 2.0.9
@mui/material: catalog: => 7.1.1
@mui/monorepo: github:mui/material-ui#29efc5bbdfe28d944c754d5be4a1c2761ec34f7a => 7.1.1
@mui/utils: catalog: => 7.1.1
@types/react: catalog: => 19.0.12
react: catalog: => 19.0.0
react-dom: catalog: => 19.0.0
typescript: ^5.8.3 => 5.8.3
Search keywords: adapterdayjs dayjs