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.46k stars 253 forks source link

Popover: Types for close() is wrong #9199

Open vishnuvardhan-s opened 2 weeks ago

vishnuvardhan-s commented 2 weeks ago

Describe the bug

The types for close() method for the Popover is currently

// node_modules/@ui5/webcomponents-react/dist/webComponents/Popover/index.d.ts

close: () => void;

But when I debug, I can see it takes in three parameters

// node_modules/@ui5/webcomponents/dist/Popup.js

close(escPressed = false, preventRegistryUpdate = false, preventFocusRestore = false) {
...
}

I want my code to pass preventFocusRestore to false which I am currently not able to without using this syntax

((popoverRef.current as any)?.close)(false, false, true);

It would be great if the types are updated so that I don't have to typecast the ref to any

Isolated Example

https://stackblitz.com/edit/github-bdj64s?file=src%2FApp.tsx

Reproduction steps

1. 2. 3. ...

Expected Behaviour

It should have the types of the arguments

Screenshots or Videos

No response

UI5 Web Components for React Version

1.26.2

UI5 Web Components Version

1.23.3

Browser

Chrome

Operating System

MacOS

Additional Context

No response

Relevant log output

No response

Organization

SAP

Declaration

MarcusNotheis commented 2 weeks ago

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,

it looks like not all parameters of of close() method of the Popover (inherited from Popup) are part of the custom element manifest: https://unpkg.com/browse/@ui5/webcomponents@1.23.3/dist/custom-elements-internal.json Line 12530 (Popover/onClose) and Line 12766 (Popup/onClose) have no parameters at all.

nnaydenow commented 1 week ago

Hi @vishnuvardhan-s,

These parameters are not described in the types since they are used internally. For preventing focus restore we provide property called preventFocusRestore to the ui5-popover (https://sap.github.io/ui5-webcomponents/components/Popover/#preventfocusrestore). Could you please check if this property will suite for your use case?