Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

117
Views
<webview>: An action has already been taken for this "dialog" event

I need to display a webpage in webview and have certain navigations happen. Since webview does not let confirm dialogs pass through, I want to listen to the dialog events in the webview and then pass my own custom dialog and have the user action be the one that's going to be taken.

Listening to the webview for the event is easy enough:

webview.addEventListener('dialog', this.onDialogOpen);

And then I open the dialog with the said method:

private onDialogOpen (e: any): void {
    this.dialogOn = true;
    this.dialogEvent = e;
}

Now what I want is the user to interact with my dialog and pass its action to this dialogEvent, as this:

<button onclick="onDialogAction()">OK</button>

And run the script:

public onDialogAction() {
       this.dialogEvent.dialog.ok();
}

But at this point I get the error in the title:

webview: An action has already been taken for this "dialog" event.

As I understand, for some reason, the DialogEvent gets 'outdated' once some time has passed. If I say 'this.dialogEvent.dialog.ok();' inside onDialogOpen it works. I can also call 'this.dialogEvent.dialog.ok();' from any other method if I call it from onDialogOpen. However if I say, setTimeout within that onDialogOpen, it stops working again.

What would be the cause of this and what would be the right way to get around this?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The solution was simple for anyone coming to this question from a search:

Simply adding

this.dialogEvent.preventDefault();

to onDialogOpen() does the trick. The problem was the default action for any dialog event is to go with cancel, and that gets triggered for some reason when DOM is loaded. But any dialog event can be prevented from going to default with preventDefault() apparently.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!