-
Notifications
You must be signed in to change notification settings - Fork 281
Description
Feature Request Description
In React, it's typical to initialize Refs with null (e.g., useRef<T>(null)), not undefined. However, the opener prop of popover components like the Popover, Menu, etc. doesn't accept null, which leads to TypeScript errors when assigning ref.current directly.
I've created an example that demonstrates this behavior: https://stackblitz.com/edit/ui5wcr-popover-7zbddenb?file=src%2FApp.tsx
In our wrapper, we can't simply convert undefined to null, as they are distinct types and we want to preserve the original value passed in.
Proposed Solution
Allow null for opener property.
Proposed Alternatives
If this is too much effort or could lead to unintended side-effects we can document a way to prevent this error by setting undefined explicitly:
const btnRef = useRef<ButtonDomRef>(null); <Popover
open={open}
opener={btnRef.current ?? undefined}
onClose={() => {
setOpen(false);
}}
>
Content
</Popover>Organization
UI5WCR
Additional Context
No response
Priority
Medium
Privacy Policy
- I’m not disclosing any internal or sensitive information.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Completed