Luvias
Luvias

Reputation: 570

Javascript click not works on Chrome Devtools

I am trying to click this button on this page https://froala.com/demo-editor-new/

enter image description here

It works fine if I click using my mouse, but it does not work when I run this code from the Chrome Dev Tools document.querySelector('#moreMisc-1').click()

Any idea what the problem could be here?

Upvotes: 1

Views: 64

Answers (1)

Eduardo Poço
Eduardo Poço

Reputation: 3089

The click handler first checks if the event is a real user gesture and then shows the menu. It is achieved with event.isTrusted property:

https://developer.mozilla.org/en-US/docs/Web/API/Event/isTrusted

Any javascript artificial dispatching of events generates events with isTrusted set to false. It is only true in genuine user actions.

Upvotes: 3

Related Questions