Skip to content

Can't prevent dropped file from opening in webview #13811

Closed

Description

@EdwardLiao
  • Electron Version: 2.0.3
  • Operating System (Platform and Version): macOS 10.13.5

Expected Behavior
By default, dropping a file to a webview will trigger electron to open it within the webview.
I expect there is some way to prevent it.

Actual behavior
I can not find a way to prevent it.

To Reproduce

I'm trying to prevent the default drop behavior of Electron by adding the following code to renderer process.

document.ondragover = document.ondrop = (ev) => {
    ev.preventDefault()
    ev.stopPropagation();
}
  
document.body.ondrop = (ev) => {
    ev.preventDefault();
    ev.stopPropagation();
}

It did work for any non-webview elements, but if I drop the file to a webview, the webview will open the dropped file.

Activity

  1. welcome commented on Jul 26, 2018

    @welcome

    👋 Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.

    To help make it easier for us to investigate your issue, please follow the contributing guidelines.

  2. sofianguy commented on Jul 27, 2018

    @sofianguy
    Contributor

    Thanks for reaching out!

    Because we treat our issues list as the team's backlog, we close issues that are questions since they don't represent a task needing to be completed. For most questions about Electron there are a lot of options.
    Check out the Electron community. There are also a bunch of helpful people in this community forum that should be willing to point you in the right direction.

  3. nornagon commented on Jul 27, 2018

    @nornagon
    Contributor

    #12655 disabled this behaviour by default in top-level frames. It should be disabled for webview too (though is in general fairly unstable, and I'd recommend finding a way to do what you need without it. Consider <iframe>s or an architecture that doesn't require embedding content).

    Reopening this because this behaviour shouldn't be happening in webviews.

  4. added a commit that references this issue on Sep 26, 2018
    8b31cce
  5. added a commit that references this issue on Sep 27, 2018
    2470078
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions