Bug 37789 - <input type="search"> Cancel Button Should Fire an Event
Summary: <input type="search"> Cancel Button Should Fire an Event
Status: RESOLVED CONFIGURATION CHANGED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC OS X 10.5
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-04-18 23:28 PDT by Joseph Pecoraro
Modified: 2023-12-11 06:26 PST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joseph Pecoraro 2010-04-18 23:28:18 PDT
Web Developers want to be able to detect when the user pressed the Cancel button in a search input. Currently there is no reliable way to detect this. I think firing an event makes sense.

I would suggest firing a bubbling, non-cancelable "cancel" event from the input element.

The following would be an example of usage:

    <input type="search" id="x">
    <script>
    var elem = document.getElementById('x')
    elem.addEventListener('cancel', function(e) {
        alert('You Clicked Cancel!');
        // e.target would be elem
    }, false);
    </script>
Comment 1 Alexey Proskuryakov 2010-04-20 16:40:12 PDT
See also: bug 34393.
Comment 2 Kent Tamura 2010-07-22 17:47:49 PDT
Since r63929, WebKit dispatches 'input' event immediately on the cancel button click, and will dispatch 'change' event when the focus is moved from the input field.  I think this behavior is enough.
Comment 3 Anne van Kesteren 2023-12-11 06:26:23 PST
Agreed with comment 2.