SAP / ui5-webcomponents

UI5 Web Components - the enterprise-flavored sugar on top of native APIs! Build SAP Fiori user interfaces with the technology of your choice.
https://sap.github.io/ui5-webcomponents/
Apache License 2.0
1.47k stars 254 forks source link

DatePicker: Wrong value set when formatPattern MM/YYYY used #8949

Closed gitgmehja closed 1 month ago

gitgmehja commented 1 month ago

Describe the bug

if formatPattern MM/YYYY is set and user chooses for example 01/2017 the value is somehow changed to 01/2016

Isolated Example

No response

Reproduction steps

  1. open https://sap.github.io/ui5-webcomponents-react/?path=/story/inputs-datepicker--default
  2. change formatPattern to MM/YYYY
  3. try to select 01/2017

Expected Behaviour

selected value should be the one the user chose, but it changes to some other year 01/2016 or 01/2015 image

Screenshots or Videos

No response

UI5 Web Components for React Version

1.26.3

UI5 Web Components Version

1.26.3

Browser

Chrome

Operating System

No response

Additional Context

No response

Relevant log output

No response

Organization

No response

Declaration

Lukas742 commented 1 month ago

Hi @gitgmehja

Thanks for reporting! I'll forward this issue to our UI5 Web Components Colleagues as the affected component is developed in their repository.


Hi colleagues, the issue was only reproducible for me if Assets were imported first. I checked with English and German localization. Here you can find a StackBlitz example showing this behavior using only ui5wc without our wrapper: https://stackblitz.com/edit/github-icmnlc?file=main.js

GerganaKremenska commented 1 month ago

Hello @gitgmehja,

The issue is not reproducible in storybook, or in the exmaple provided by @Lukas742. I have attached videos testing in storybook and Blitz.

Can you please provide more information on how to reproduce this issue?

Best Regards, Gergana

https://github.com/SAP/ui5-webcomponents/assets/22882174/aada3779-54b5-4e7e-bfca-7727d4a97fec

https://github.com/SAP/ui5-webcomponents/assets/22882174/06a76229-5fee-405d-8bee-bb387a3771b9

Lukas742 commented 1 month ago

Hi @GerganaKremenska

Maybe I can help. I suspect it's related to the locale being used. I've forked and updated my example to include the information retrieved by getLocale and the user agent.

https://stackblitz.com/edit/github-icmnlc-fhaoxh?file=main.js

Chrome en-GB:

https://github.com/SAP/ui5-webcomponents/assets/9749730/e8119a22-dd60-444e-bd2d-b8006fca63b2

Firefox de-DE:

https://github.com/SAP/ui5-webcomponents/assets/9749730/8380280c-dcca-45fa-8628-83bc32b1c1c7

gitgmehja commented 1 month ago

thanks @Lukas742

GerganaKremenska commented 1 month ago

Hello Colleagues,

Can you take over the issue regarding date picker? Looks like when locale is used there is an issue. Lukas previous comments have steps to reproduce.

Best Regards, Gergana

unazko commented 1 month ago

Hello @gitgmehja,

I'm referring to an already existing note about this behavior related to the date components from the openui5 project:

Cause The year component of the "pattern" property of the DateFormat object is using the parameter for the ISO year-week calendar.

The year number of the ISO week very often differs from the Gregorian year number for dates close to 1 January. For example, 29 December 1986 is ISO 1987-W01-1, i.e., it is in year 1987 instead of 1986.

Resolution Use "yyyy" (lowercase) instead of "YYYY" (uppercase) when defining the pattern of the DateFormat object.

The situation here is exactly the same as the same DateFormat class is used to perform the dates formatting and parsing.

Best regards, Boyan