Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Confirm Delete for Files #4982

Open
2 tasks done
MentalGear opened this issue Mar 6, 2024 · 0 comments
Open
2 tasks done

Confirm Delete for Files #4982

MentalGear opened this issue Mar 6, 2024 · 0 comments
Labels

Comments

@MentalGear
Copy link

MentalGear commented Mar 6, 2024

Initial checklist

  • I understand this is a feature request and questions should be posted in the Community Forum
  • I searched issues and couldn’t find anything (or linked relevant results below)

Problem

I find the delete buttons dangerously exposed, especially when people scroll on touch devices.

It would be great, if we could control this with an optional confirm dialog.

Solution

Provide a new event "before-file-remove" that allows to cancel the delete if necessary by custom UI action.

Alternatives

As a workaround I use the following for now (posting it for others to use as well):

    function injectConfirmDialogForDeletion(e) {
        const deleteUploadBtn = ".uppy-Dashboard-Item-action--remove"
        const target = e.target?.closest(deleteUploadBtn)
        // console.log(target)

        if (!target) return

        if (target) {
            const out = confirm("Delete this uploaded file?")
            if (!out) {
                e.preventDefault()
                e.stopPropagation()
            }
        }
    }


    uppyContainer.addEventListener(
        "click",
        injectConfirmDialogForDeletion,
        { capture: true } // prioritizes this event listener
    )
@MentalGear MentalGear changed the title Confirm Delete for file-removed Confirm Delete for Files Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant