Bug 37789 - <input type="search"> Cancel Button Should Fire an Event
Summary: <input type="search"> Cancel Button Should Fire an Event
Status: NEW
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
Depends on:
Reported: 2010-04-18 23:28 PDT by Joseph Pecoraro
Modified: 2010-07-22 17:47 PDT (History)
2 users (show)

See Also:


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">
    var elem = document.getElementById('x')
    elem.addEventListener('cancel', function(e) {
        alert('You Clicked Cancel!');
        // e.target would be elem
    }, false);
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.