Skip to content

touchend listener on document prevents listening for clicks on dom elements (web) #4752

@lucasmerlin

Description

@lucasmerlin

Describe the bug
Egui is registering a touchend event listener on the document and is calling preventdefault on the event. This prevents any touch interactions with dom elements shown on top of the canvas.

To Reproduce

Paste the following in the console on egui.rs (to create a simple html dialog):

let dialog = document.createElement("dialog");
let button = document.createElement("button");
button.innerHTML = "Hello";
dialog.appendChild(button);
button.onclick = () => alert("button click!!");
document.body.appendChild(dialog);
dialog.show()

Clicking the button now does nothing. (Make sure you enabled the device toolbar and set it to e.g. iPhone SE)

If we forcefully remove the egui touchend listener from document via

document.removeEventListener("touchend", getEventListeners(document).touchend[0].listener)

the button will become clickable.

Expected behavior
Egui shouldn't interfere with other dom elements. Maybe the touchend listener doesn't need preventDefault or it could be made configurable.

Additional context

The listener is added here:

install_touchend(runner_ref, &document)?;

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething is brokenwebRelated to running Egui on the web

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions