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

[fields] Support format without separator #12489

Merged
merged 4 commits into from
Mar 20, 2024

Conversation

flaviendelangle
Copy link
Member

Fix #12487

@flaviendelangle flaviendelangle added bug 🐛 Something doesn't work component: pickers This is the name of the generic UI component, not the React module! labels Mar 19, 2024
@flaviendelangle flaviendelangle self-assigned this Mar 19, 2024
@@ -214,6 +214,10 @@ export class AdapterLuxon implements MuiPickersAdapter<DateTime, string> {
// Extract escaped section to avoid extending them
const catchEscapedSectionsRegexp = /''|'(''|[^'])+('|$)|[^']*/g;

// This RegExp tests if a string is only mad of supported tokens
Copy link
Member Author

Choose a reason for hiding this comment

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

This method was escaping tokens when they were not separated by any character.

.join('|')})`,
'g', // used to get access to lastIndex state
);
// This RegExp tests if the beginning of a string corresponds to a supported token
Copy link
Member Author

@flaviendelangle flaviendelangle Mar 19, 2024

Choose a reason for hiding this comment

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

I reworked this method because it was duplicating the 1st character of the 2nd token (once inside the token and once as a separator).

Since we catch the whole token in one passage in the loop, we can replace the for with a while and stop populating currentTokenValue incrementaly. This makes the whole behavior simplet IMHO.

Now we also support glued tokens (e.g: HHMM) which forces us to check if a word is composed only of tokens and if so to split them and create the sections.
The only thing we can't support is stuff like YYYYdeMM but I think it's a very very weird format 😬

@mui-bot
Copy link

mui-bot commented Mar 19, 2024

Deploy preview: https://deploy-preview-12489--material-ui-x.netlify.app/

Generated by 🚫 dangerJS against c9b77e1

@flaviendelangle flaviendelangle marked this pull request as ready for review March 19, 2024 14:36
Copy link
Member

@alexfauquette alexfauquette left a comment

Choose a reason for hiding this comment

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

👍

@flaviendelangle flaviendelangle merged commit 6787e71 into mui:next Mar 20, 2024
17 checks passed
@flaviendelangle flaviendelangle deleted the format-no-sepatator branch March 20, 2024 07:42
@flaviendelangle flaviendelangle added needs cherry-pick The PR should be cherry-picked to master after merge and removed needs cherry-pick The PR should be cherry-picked to master after merge labels Mar 20, 2024
thomasmoon pushed a commit to thomasmoon/mui-x that referenced this pull request Sep 9, 2024
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.

[pickers] Cannot display time with format without spaces like "HHmm" correctly
3 participants