-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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 RTL out of the box #6715
Conversation
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
11e44d6
to
59f3c64
Compare
These are the results for the performance tests:
|
The current strategy is to split the format when there is a space, and consider that as a group of sections we force it to be left to right. In those groups, each section s isolated with direction automatically deduced from its content For example:
(I added some spaces and line breaks to simplify the reading) This forces sections to stay in the same position, whatever the content (digit, ltr, or rtl text) is. Moreover, it ensures we can compute the order in which elements are visible. The management of the right/left arrows probably needs to be redesigned. For now it's a bit nasty because I did not found where to put it Here is a code sandbox to experiment behavior date-fns-jalali : full screen | with code |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
@alexfauquette is this ready for review ? |
@@ -656,3 +700,55 @@ export const clampDaySection = <TDate, TSection extends FieldSection>( | |||
}; | |||
}); | |||
}; | |||
|
|||
export const getSectionOrder = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export const getSectionOrder = ( | |
/** | |
* Return a description of sections order from left to right. | |
**/ | |
export const getSectionOrder = ( |
Tremendous work on this part. 🚀 With A few general notes:
Screen.Recording.2022-11-29.at.23.19.13.mov
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great !
packages/x-date-pickers/src/internals/hooks/useField/useField.interfaces.ts
Show resolved
Hide resolved
packages/x-date-pickers/src/internals/hooks/useField/useField.interfaces.ts
Show resolved
Hide resolved
packages/x-date-pickers/src/internals/hooks/useField/useField.utils.ts
Outdated
Show resolved
Hide resolved
Probably an error when computing the start/end indexes of the selected characters. I will have a look
Yes, I've faced problems with moment-hijri because there is inconsistencies between parse and format. Not sure if it's a bug or misuse. I opened an issue, but no answer: xsoh/moment-hijri#83 |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
We have several problem to support the editing of moment plugins
I'm trying to see how to fix the 2nd one, already did the 1st one locally |
@alexfauquette I opened a PR on your repo (alexfauquette#7) to try fixing |
I confirm it fixes the problem |
The idea is probably similar on |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
Yes, I will have a look tomorrow and close the issue if it works 👍 @flaviendelangle @LukasTy I've a last concern about this implementation: For simplicity, the current solution is adding Unicode character in both |
IMHO—fields implementation is already very complex as-is. I'd lean towards leaving this behaviour in both modes. Besides, it might allow us to spot any possible future issues, which would possibly be missed (because we wouldn't be working with |
We already have invisible characters in LTR for the numeric editing anyway. |
On The adapter also have the problem of adding gregorian months and not hijri ones. But their is a bigger problem linked to the library itself. Let assume you have a field with When you press the key UP on months it roughly does the following: const initialMonth = utils.parse('02', 'iMM');
const newMonth =utils.addMonths(initialMonth, 1);
const new SectionValue = utils.format(newMOnth, 'iMM' ); The problem, with
The example is in the issue I opened |
589367c
to
423c966
Compare
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
@alexfauquette how about adding a warning on the doc for |
Good for me |
Follow up of #6571