New issue
Advanced search Search tips

Issue 883340 link

Starred by 1 user

Issue metadata

Status: ExternalDependency
Owner: ----
Components:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 3
Type: Feature



Sign in to add a comment

HTML5 Media Capture "cancel" event

Project Member Reported by douglasparker@google.com, Sep 12

Issue description

Steps to reproduce the problem:
1. Visit http://jsbin.com/cuhihogugi/2/edit?html,output on Chrome Android
2. Click "Choose file".
3. The media capture UI should display to take a photo.
4. Press "Cancel"
5. Observe that no event is triggered.

What is the expected behavior?
An event of some kind should trigger.

What went wrong?
The "change" event doesn't trigger because the `file` attribute on the <input /> was `null` before the user pressed cancel, and `null` afterwards so no "change" really occurred. That's actually pretty reasonable, however the page should receive SOME kind of event to know that the user performed an action that it may need to react to.

A simple "cancel" event or a "done" event which triggers on photo capture or cancel would solve this problem.

Did this work before? No 

Does this work in other browsers? No
 https://github.com/whatwg/html/issues/3976
https://bugs.webkit.org/show_bug.cgi?id=185086

Chrome version: 69.0.3497.92  Channel: stable
OS Version: 
Flash Version: 

The lack of this event is incredibly limiting to developers. As an example, consider the following use case:

I have a site which requires the user to provide a photo to continue. The user presses a button to open the file picker. Once they capture a photo we progress to the next screen and do something with the photo. However, if the user presses cancel, it can be useful to show a dialog which says "Hey, we need photo for these reasons and can't proceed without one." before re-opening the file picker.

This UI is impossible in the current spec, because no "cancel" event is defined. There would be no way to know when the user canceled the picker and the UI needs to designed so that it does not require this information.

There is a workaround where you can listen to `document.onfocus`, but this is a hack at best and does not work in mobile Safari (which has no viable workaround to my knowledge).

Related links:
Media Capture Spec: https://www.w3.org/TR/html-media-capture/
WebKit bug: https://bugs.webkit.org/show_bug.cgi?id=185086
StackOverflow: https://stackoverflow.com/questions/4628544/how-to-detect-when-cancel-is-clicked-on-file-input
 
Labels: Needs-Triage-M69
Components: -Blink>Media Blink>Forms>File
Labels: -Type-Bug -Pri-2 Pri-3 Type-Feature
Status: ExternalDependency (was: Unconfirmed)

Sign in to add a comment