Bug 24129

Summary: Dropdown list doesn't open when onmousedown handler returns false
Product: WebKit Reporter: jasneet <jasneet>
Component: UI EventsAssignee: Nobody <webkit-unassigned>
Status: RESOLVED INVALID    
Severity: Normal CC: ahmad.saleem792, ap, barraclough, bfulgham, ian, jasneet, rakeshchaitan
Priority: P2 Keywords: HasReduction
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
URL: http://www.emule-island.com/
Attachments:
Description Flags
reduced testcase none

Description jasneet 2009-02-24 11:22:31 PST
I Steps:
Go to http://www.emule-island.com/

II Issue : 
In right column, Dropdown for Films is not working. On clicking dropdown arrow, doesn't show dropdown list

III Conclusion:
In the javascript, they are setting the <div>s with className "menuItem" with the following: 
     alldiv[i].onmousedown = selectMenuItem;

in which selectMenuItem  is a function defined as: 
function selectMenuItem(e) {
	if(document.all)e = event;
	if (e.target) source = e.target; 
				else if (e.srcElement) source = e.srcElement;
			if (source.nodeType == 3) // defeat Safari bug
				source = source.parentNode;
				
	return false;
}

This is causing the issue in webkit. 

IV Other Browsers:
FF3: OK
IE7: OK 

V Nightly tested: 41018

Bug in Chromium : http://code.google.com/p/chromium/issues/detail?id=6932
Comment 1 jasneet 2009-02-24 11:22:50 PST
Created attachment 27923 [details]
reduced testcase
Comment 2 Gavin Barraclough 2012-03-08 18:57:36 PST
This doesn't look like an issue in the JSC part of the code, like bindings or events?
Comment 3 Rakesh 2012-03-12 13:24:44 PDT
(In reply to comment #2)
> This doesn't look like an issue in the JSC part of the code, like bindings or events?
The event handler "selectMenuItem" in the script mentioned above returns false.
Hence the default action is prevented from JSEventListener::handleEvent() (http://trac.webkit.org/browser/trunk/Source/WebCore/bindings/js/JSEventListener.cpp#L156).

If returning false from event handler is for preventing default action then this is an expected behavior?
Comment 4 Alexey Proskuryakov 2012-03-12 13:35:36 PDT
If it still works in Firefox and IE, then it may not be expected!
Comment 5 Rakesh 2012-03-13 10:54:59 PDT
(In reply to comment #4)
> If it still works in Firefox and IE, then it may not be expected!

The specs http://dev.w3.org/html5/spec/Overview.html#event-handler-attributes says "If return value is a boolean with the value false, then cancel the event." and I think our implementation is as per specs.

Shall we keep it as it is or make it similar to Firefox/IE?
Comment 6 Alexey Proskuryakov 2012-03-13 11:28:22 PDT
I don't have a complete answer. If HTML5 is blatantly incompatible with both IE and Firefox, then the spec and WebKit should likely change. But there may be something more subtle in this particular case.
Comment 7 Ian 'Hixie' Hickson 2012-03-19 11:14:52 PDT
The event should be canceled, that's not the problem here.

The difference is that in Firefox, the dropdown drops before the event is fired.

Compare the behaviours on this test:
   http://software.hixie.ch/utilities/js/live-dom-viewer/saved/1412

The HTML spec doesn't say anything about how the widgets are implemented at that level. It differs from platform to platform, so there's not much the spec _can_ say. For compatibility, though, it seems that select widgets implemented using dropdowns should drop down before the mousedown event is fired at the DOM.
Comment 8 Ahmad Saleem 2022-09-29 10:59:01 PDT
*** Safari 16 ***

log: object "[object HTMLSelectElement]" (311 props: 0="[object HTMLOptionElement]", autocomplete="", disabled=false, form="null"...)
log: false
log: object "[object HTMLDivElement]" (288 props: align="", title="", lang="", translate=true...)
log: true

*** Chrome Canary 108 ***

log: object "[object HTMLSelectElement]" (338 props: 0="[object HTMLOptionElement]", autocomplete="", disabled=false, form="null"...)
log: false
log: object "[object HTMLDivElement]" (315 props: align="", title="", lang="", translate=true...)
log: true

*** Firefox Nightly 107 ***

log: object "[object HTMLSelectElement]" (285 props: 0="[object HTMLOptionElement]", item=function item() {\n    [native code]\n}, namedItem=function namedItem() {\n    [native code]\n}, add=function add() {\n    [native code]\n}...)

log: false

log: object "[object HTMLDivElement]" (261 props: align="", click=function click() {\n    [native code]\n}, attachInternals=function attachInternals() {\n    [native code]\n}, focus=function focus() {\n    [native code]\n}...)

log: true

_________

Just wanted to share updated results based on test case from Comment 07. It seems to me that all browsers are showing same. Can someone confirm whether something else is required? Thanks!
Comment 9 Alexey Proskuryakov 2022-09-29 12:53:54 PDT
Other browsers match Safari now, returning false from mousedown event handler prevents opening the menu.