primitives
primitives copied to clipboard
TypeError : and the error messageCannot read properties of undefined (reading 'defaultPrevented')
Bug report
Current Behavior
- We occasionally encounter errors from the monitoring tool. For example, TypeError: 'Cannot read properties of undefined' (reading 'defaultPrevented').
Expected behavior
- Should be handle incase of undefined value.
Reproducible example
- Can't reproduce
Suggested solution
We should add more condition to check event is undefined or not.
from:
if (checkForDefaultPrevented === false || !((event as unknown) as Event).defaultPrevented) {
to:
if (checkForDefaultPrevented === false || !event || !((event as unknown) as Event).defaultPrevented) {
REF: https://github.com/radix-ui/primitives/blob/main/packages/core/primitive/src/primitive.tsx#L9
Additional context
Your environment
Software | Name(s) | Version |
---|---|---|
Radix Package(s) | @radix-ui/react-dialog | ^0.1.5 |
React | n/a | |
Browser | Android | 13 |
Assistive tech | ||
Node | n/a | 18.18.2 |
npm/yarn | ||
Operating System | Android | 13 |
Hi, anyone here ?
I came across this too. I was passing an empty callback as a prop, which it appears Radix patches or modifies. So hack for me was to pass the event as an argument for the callback.