primitives icon indicating copy to clipboard operation
primitives copied to clipboard

TypeError : and the error messageCannot read properties of undefined (reading 'defaultPrevented')

Open chonlatit-tpit opened this issue 10 months ago • 1 comments

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

Screenshot 2567-04-09 at 09 57 40

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

chonlatit-tpit avatar Apr 09 '24 03:04 chonlatit-tpit

Hi, anyone here ?

chonlatit-tpit avatar Apr 18 '24 01:04 chonlatit-tpit

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.

atomcorp avatar Jul 19 '24 13:07 atomcorp