ui5-webcomponents
ui5-webcomponents copied to clipboard
[DatePicker|Calendar components]: Year increments when old Buddhist date is entered
Bug Description
Hi team,
When the configuration sets Buddhist as the calendarType and the user tries to select an old date either manually or through the calendar picker onChange
will cause the year to increment by 2. The incrementation only happens when month is April or Greater and when the Buddhist year is 2484 or less (Gregorian year 1941 or less). This is because before January 1, 1941, the Thai calendar first of the year was actually April 1st. (which is what is explained here, sap/ui/core/date/Buddhist.js#L14-L24. The reason for the incrementation is because every time the date-string is parsed/formatted the value of the year will increment by 1. For the date picker, the parse/formatting will happen during DatePicker.ts#L533?_updateValueAndFireEvents() and DatePicker.ts#L425?onBeforeRendering()
In my opinion, the logic in the date picker/calendar components are correct and the root cause likely lies within src/sap/ui/core/date/Buddhist.js#L82-L85, but the behavior between openUI5 sap.m.DatePicker and the webcomponent is different. Hence, this GH issue.
OpenUI5, only increments by 1 whereas ui5-wc increments by 2.
Open date picker, select a date. OpenUI5 does not increment whereas ui5-wc increments by 2.
For now we can focus on the behavior of the webcomponent.
Affected Component
Date Picker/Calendar Components
Expected Behaviour
Using the Buddhist Thai calendar, the user is able to manually enter a date or select a date through the picker without it being modified under the covers.
Isolated Example
https://codesandbox.io/s/ui5-webcomponents-forked-gm7tuh?file=/index.html
Steps to Reproduce
- Open the codesandbox. Enter an old date, e.g. 04/19/2490
- Click or tab out to trigger 'onChange'. Notice the value in the input has incremented by 2.
- Open the calendar picker, notice the value in the input has incremented by 1, and the year in the month picker is also incremented by 1.
- Select a date in the picker and see the value increments again.
- For comparison to openUI5's sap.m.DatePicker, you can try this snippix: https://snippix.only.sap/snippets/866084
Log Output, Stack Trace or Screenshots
No response
Priority
None
UI5 Web Components Version
main
Browser
Chrome, Edge, Firefox, Safari
Operating System
No response
Additional Context
No response
Declaration
- [X] I’m not disclosing any internal or sensitive information.
Hello colleagues,
The issue is reproduced as described by the reporter:
- Go to https://codesandbox.io/s/ui5-webcomponents-forked-gm7tuh?file=/index.html
- Select a month April or Greater and Buddhist year 2484 or less (Gregorian year 1941 or less).
- You can see that the year in the Input field is incremented by 2.
Could you please have a look?
Thank you in advance! Best regards, Ivaylo
Hello @allen138 ,
The issue was fixed with: https://github.com/SAP/ui5-webcomponents/pull/9432
Best Regards, Tsanislav
Hello @allen138 as this is only merged in the main branch (pointing to version 2.0 ), could you tell us which version do you need this to be tested and downported. In version 1.24 we will downport it by process, but do you need it for an older version?