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.51k stars 260 forks source link

Date / DateTime / Time Pickers dateValue not available when setting programmatically the value #7877

Closed ybesnehard closed 10 months ago

ybesnehard commented 10 months ago

Bug Description

When setting programmatically the value in a DatePicker the dateValue is not available (undefined) where when the value is picked by hand in the picker the dateValue is available.

Affected Component

DatePicker DateTimePicker TimePicker

Expected Behaviour

The dateValue should be available after having set programmatically the value

Isolated Example

https://codesandbox.io/s/ui5-webcomponents-forked-dccy4g?file=/src/index.js

Steps to Reproduce

  1. Open the sandbox
  2. See that the dateValue is undefined at initialization
  3. Pick a date in the picker
  4. See that the dateValue is not undefined after picking it

Log Output, Stack Trace or Screenshots

No response

Priority

Medium

UI5 Web Components Version

1.19.0

Browser

Chrome

Operating System

Windows

Additional Context

In the context of SAP Build Process Automation we would need to be able to get the date object on the picker after setting the value programmatically

Organization

SAP

Declaration

MapTo0 commented 10 months ago

Hello @ybesnehard,

You are trying to call a getter for the dateValue before the component is upgraded as Web Component at all. Therefore non of the component API is working at that time. I would suggest you to use a util to parse your date to an object instead of the component API. Or wait until the component is upgraded.

Check window.customElements.whenDefined API.

Best Regards, Martin

ybesnehard commented 10 months ago

Many Thanks for the info, will do that !