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

[ui5-special-date]: value does not respect format-pattern of ui5-calendar #9067

Closed
1 task done
floa93 opened this issue May 27, 2024 · 1 comment · Fixed by #9086
Closed
1 task done

[ui5-special-date]: value does not respect format-pattern of ui5-calendar #9067

floa93 opened this issue May 27, 2024 · 1 comment · Fixed by #9086
Assignees
Labels
bug This issue is a bug in the code Low Prio TOPIC B

Comments

@floa93
Copy link

floa93 commented May 27, 2024

Bug Description

If a ui5-special-date is given with a value(e.g. value="20240528" ) in the format-pattern of the parent ui5-calendar(e.g. format-pattern="yyyyMMdd" ) an javascript error occurs and the calendar doesn't render.

This calendar typescript code uses the Javascript date function

const dateFromValue = new Date(date.value);
, which does not respect the format-pattern like done in
const date = this.getFormat().parse(dateString);
to check if this is a valid special date.

Affected Component

ui5-special-date

Expected Behaviour

The calendar special date should be usable with the custom format-pattern given

Isolated Example

No response

Steps to Reproduce

<ui5-calendar format-pattern="yyyyMMdd" hide-week-numbers min-date="20240501" max-date="20241224">
    <ui5-special-date slot="specialDates" ui5-special-date value="20240528" type="Type01"></ui5-special-date>
</ui5-calendar>

Workaround: use a valid new date() format like yyyy-MM-dd

<ui5-calendar format-pattern="yyyy-MM-dd" hide-week-numbers min-date="2024-05-01" max-date="2024-12-24">
    <ui5-special-date slot="specialDates" ui5-special-date value="2024-05-28" type="Type01"></ui5-special-date>
</ui5-calendar>

### Log Output, Stack Trace or Screenshots

CalendarDate.js:143 Uncaught (in promise) Error: Date parameter must be a JavaScript Date object: [Invalid Date].
at CalendarDate.fromLocalJSDate (CalendarDate.js:143:1)
at Calendar.js:186:46
at Array.forEach ()
at get _specialCalendarDates (Calendar.js:181:1)
at Calendar.block0 (CalendarTemplate.lit.js:3:3983)
at executeTemplate (executeTemplate.js:12:1)
at Calendar.render (UI5Element.js:104:31)
at updateShadowRoot (updateShadowRoot.js:20:1)
at Calendar._render (UI5Element.js:580:29)
at renderImmediately (Render.js:31:1)


### Priority

None

### UI5 Web Components Version

1.24.3

### Browser

Chrome, Edge, Firefox

### Operating System

Windows

### Additional Context

Its not a big issue since an easy workaround is to just use a valid new date() format like yyyy-MM-dd
```

Organization

SAP

Declaration

  • I’m not disclosing any internal or sensitive information.
@floa93 floa93 added the bug This issue is a bug in the code label May 27, 2024
@plamenivanov91
Copy link
Contributor

Hello @SAP/ui5-webcomponents-topic-b,

It seems value="20240528" is not recognized as valid date in our code.

Is this expected behavior ?

Also, the issue is reproducible in the main branch.

Regards,
Plamen Ivanov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug in the code Low Prio TOPIC B
Projects
Status: Completed
Development

Successfully merging a pull request may close this issue.

3 participants