Skip to content

Commit

Permalink
Add a "cancel" event for when file upload selection is unchanged
Browse files Browse the repository at this point in the history
Closes #6376.
  • Loading branch information
domenic authored Jul 8, 2021
1 parent fdb64fd commit 9c4374f
Showing 1 changed file with 28 additions and 10 deletions.
38 changes: 28 additions & 10 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -47916,11 +47916,11 @@ ldh-str = &lt; as defined in <a href="https://tools.ietf.org/html/rfc1034#
no more than one file in the list of <span data-x="concept-input-type-file-selected">selected
files</span>.</p>

<p>The element's <span>input activation behavior</span> is to run the following steps:</p>
<p>The <span>input activation behavior</span> for such an element <var>element</var> is:</p>

<ol>
<li><p>If the algorithm is invoked when the element's <code>Window</code> object does not have
<span>transient activation</span>, then return without doing anything else.</p></li>
<li><p>If the algorithm is invoked when <var>element</var>'s <span>relevant global object</span>
does not have <span>transient activation</span>, then return.</p></li>

<li>
<p>Run these steps <span>in parallel</span>:</p>
Expand All @@ -47929,15 +47929,33 @@ ldh-str = &lt; as defined in <a href="https://tools.ietf.org/html/rfc1034#
<li><p>Optionally, wait until any prior execution of this algorithm has terminated.</p></li>

<li><p>Display a prompt to the user requesting that the user specify some files. If the <code
data-x="attr-input-multiple">multiple</code> attribute is not set, there must be no more than
one file selected; otherwise, any number may be selected. Files can be from the filesystem or
created on the fly, e.g., a picture taken from a camera connected to the user's
device.</p></li>
data-x="attr-input-multiple">multiple</code> attribute is not set on <var>element</var>, there
must be no more than one file selected; otherwise, any number may be selected. Files can be
from the filesystem or created on the fly, e.g., a picture taken from a camera connected to the
user's device.</p></li>

<li><p>Wait for the user to have made their selection.</p></li>

<li><p><span>Update the file selection</span> for the <code>input</code> element.</p></li>
<li><p>If the user dismissed the prompt without changing their selection, then <span>queue an
element task</span> on the <span>user interaction task source</span> given <var>element</var>
to <span data-x="concept-event-fire">fire an event</span> named <code
data-x="event-cancel">cancel</code> at <var>element</var>, with the <code
data-x="dom-Event-bubbles">bubbles</code> attribute initialized to true.</p></li>

<li><p>Otherwise, <span>update the file selection</span> for <var>element</var>.</p></li>
</ol>

<p class="note">As with all user interface specifications, user agents have a good deal of
freedom in how they interpret these requirements. The above text implies that a user either
dismisses the prompt or changes their selection; exactly one of these will be true. But the
mapping of these possibilities to specific user interface elements is not mandated by the
standard. For example, a user agent might interpret clicking the "Cancel" button when files were
previously selected as a change of selection to select zero files, thus firing <code
data-x="event-input">input</code> and <code data-x="event-change">change</code>. Or it might
interpret such a click as a dismissal that leaves the selection unchanged, thus firing <code
data-x="event-cancel">cancel</code>. Similarly, it's up to the user agent whether re-selecting
the same files counts as were previously selected counts as a dismissal, or as a change of
selection.</p>
</li>
</ol>

Expand Down Expand Up @@ -123744,8 +123762,8 @@ INSERT INTERFACES HERE
<tr> <!-- cancel -->
<td> <dfn event for="HTMLElement"><code data-x="event-cancel">cancel</code></dfn>
<td> <code>Event</code>
<td> <code>dialog</code> elements
<td> Fired at <code>dialog</code> elements when they are canceled by the user (e.g. by pressing the Escape key)
<td> <code>dialog</code> elements, <code>input</code> elements
<td> Fired at <code>dialog</code> elements when they are canceled by the user (e.g., by pressing the Escape key), or at <code>input</code> elements in the <span data-x="attr-input-type-file">File</span> state when the user does not change their selection

<tr> <!-- change -->
<td> <dfn event for="HTMLElement"><code data-x="event-change" id="event-input-change">change</code></dfn>
Expand Down

0 comments on commit 9c4374f

Please sign in to comment.