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

[pickers] Do not loose the translations when using nested LocalizationProvider with each a localeText prop #6895

Merged
merged 5 commits into from
Nov 18, 2022

Conversation

flaviendelangle
Copy link
Member

No description provided.

@flaviendelangle flaviendelangle added bug 🐛 Something doesn't work component: pickers This is the name of the generic UI component, not the React module! labels Nov 17, 2022
@flaviendelangle flaviendelangle self-assigned this Nov 17, 2022
@flaviendelangle flaviendelangle changed the title [pickers] Fix nested LocalizationProvider translations behaviors [pickers] Fix nested LocalizationProvider translations behaviors Nov 17, 2022
@@ -56,10 +56,15 @@ export function LocalizationProvider<TDate>(inProps: LocalizationProviderProps<T
MuiPickersAdapterContext,
) ?? { utils: undefined, localeText: undefined };

const tempLocaleText = React.useMemo(
Copy link
Member Author

Choose a reason for hiding this comment

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

Otherwise when inProps.localeText is not undefined, we loose the parent one.

@mui-bot
Copy link

mui-bot commented Nov 17, 2022

Messages
📖 Netlify deploy preview: https://deploy-preview-6895--material-ui-x.netlify.app/

These are the results for the performance tests:

Test case Unit Min Max Median Mean σ
Filter 100k rows ms 675.7 1,382 1,382 970.92 257.816
Sort 100k rows ms 769.4 1,253.2 769.4 999.94 182.348
Select 100k rows ms 183.4 360.3 290.3 286.8 59.06
Deselect 100k rows ms 152 288.2 229.6 223.14 45.726

Generated by 🚫 dangerJS against 99c618c

@flaviendelangle flaviendelangle changed the title [pickers] Fix nested LocalizationProvider translations behaviors [pickers] Do not loose the translations when using nested LocalizationProvider with each a localeText prop Nov 17, 2022
Comment on lines 68 to 71
const localeText = React.useMemo(
() => ({ ...props.localeText, ...parentLocaleText, ...inLocaleText }),
[props.localeText, parentLocaleText, inLocaleText],
);
Copy link
Member

Choose a reason for hiding this comment

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

props.localeText is not obvious to get

What about moving this after props destructuring to be able to write

() => ({ ...defaultizedLocaleText, ...parentLocaleText, ...inLocaleText }),

Copy link
Member Author

Choose a reason for hiding this comment

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

OK for me, I'll just rename defaultizedLocaleText into themeLocaleText to make clear that it can only contain the theme value and never the value from the inProps

@flaviendelangle flaviendelangle merged commit 32c804b into mui:next Nov 18, 2022
@flaviendelangle flaviendelangle deleted the localization-nesting branch November 18, 2022 07:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: pickers This is the name of the generic UI component, not the React module!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants