react.dev icon indicating copy to clipboard operation
react.dev copied to clipboard

Synthetic Clicks Now Allowed?

Open abrdgrt opened this issue 1 year ago • 5 comments
trafficstars

I'm just finding out that synthetic clicks (isTrusted: false) are now allowed in react, please from what version was this implemented, what was the reason for the change and lastly would it be reverted in the future?

abrdgrt avatar Jan 16 '24 05:01 abrdgrt

Synthetic clicks refer to a technique where a program simulates user clicks on a computer system, in the context of ReactJS or any other front-end framework, these are generally not a built-in feature or explicitly allowed practice. They typically refer to programmatically generated mouse clicks, often used for testing or malicious purposes like security exploits.

renaldodev avatar Jan 17 '24 03:01 renaldodev

Hanks for taking time out of your day to reply. I'm aware, to be specific I'm referring to clicks with the event - isTrusted set as false

Do you know the answer to the question I asked?

abrdgrt avatar Jan 17 '24 06:01 abrdgrt

ReactJS itself does not directly implement the generation of synthetic events with isTrusted set to false. If you need to create a simulated event with isTrusted set to false in React, you would have to do it using plain JavaScript, outside the scope of React's built-in event handling system. This is because React's Synthetic Event system is not designed for creating artificial events but rather for handling real user interactions in a cross-browser compatible way.

renaldodev avatar Jan 17 '24 09:01 renaldodev

ReactJS itself does not directly implement the generation of synthetic events with isTrusted set to false. If you need to create a simulated event with isTrusted set to false in React, you would have to do it using plain JavaScript, outside the scope of React's built-in event handling system. This is because React's Synthetic Event system is not designed for creating artificial events but rather for handling real user interactions in a cross-browser compatible way.

I'll take it you do not understand the question I'm asking or you do not know the answer to it. It used to be that you couldn't use .click() on react websites in the past, websites like web.whatsapp.com could not be operated without using frameworks like puppeteer which supported synthetic clicks and sets them as trusted. It's no longer the case now, I am asking which version this came to be, why it was changed (so I'll know if I'm to expect a change like that in the future)

abrdgrt avatar Jan 17 '24 09:01 abrdgrt

Hi. The allowance of synthetic clicks with isTrusted: false in React was introduced in React 17. This change was made to align React's behavior with the DOM specification and to provide a more predictable and consistent event system. I hope this helps.

Darya0333 avatar Jun 01 '24 09:06 Darya0333