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.56k stars 267 forks source link

Popover: Types for close() is wrong #9199

Closed vishnuvardhan-s closed 3 months ago

vishnuvardhan-s commented 5 months 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 5 months 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 4 months 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?

github-actions[bot] commented 4 months ago

Hello, everyone! The issue has been inactive for 21 days. If there are still questions or comments, please feel free to continue the discussion. Inactive issues will be closed after 7 days!

vishnuvardhan-s commented 3 months ago

Thank you @nnaydenow! Closing the issue