Opened 5 years ago

Closed 3 years ago

#17686 closed defect (patchwelcome)

[regression] Cannot select drop down menu items when displaying on top of silverlight (MacOS + Firefox only)

Reported by: neville1355 Owned by: bill
Priority: undecided Milestone: 1.13
Component: Dijit Version: 1.9.2
Keywords: Cc:
Blocked By: Blocking:

Description

Essentially, we have dojo + silverlight running at the same time. In our particular case, we have a dijit/Toolbar displaying at the top which drives the silverlight content underneath. The toolbar contains dijit/form/DropDownButton widgets and dijit/DropDownMenus therein. As the user selects a menu, we navigate through our application appropriately.

Since 1.9.2, the menu items aren't receiving click events when clicked, under the specific conditions:

1) Mac OS + Firefox 26 2) Only when the drop down menu is displayed on top of Silverlight

If we hide silverlight, the drop down menu will behave as expected.

I narrowed down the cause to specifically changes from 1.9.0 to 1.9.2 in on.js. Specifically, the "arrowed" line below causes the problem. If I comment out this code, or if I revert this file back to 1.9.0, everything works fine.

//on.js
has.add("event-focusin", function(global, doc, element){
	return 'onfocusin' in element || (element.addEventListener && (function () {
		var hasFocusInEvent = false;
		function testFocus() {
			hasFocusInEvent = true;
		}

		try {
			var element = doc.createElement('input'),
				activeElement = doc.activeElement;
			element.style.position = 'fixed';
			element.addEventListener('focusin', testFocus, false);
			doc.body.appendChild(element);
			element.focus(); <=== This line causes the problem
			doc.body.removeChild(element);
			element.removeEventListener('focusin', testFocus, false);
			activeElement.focus();
		} catch (e) 
		{
			debugger;
		}

		return hasFocusInEvent;
	})());
});

I've attached a standalone test page that demonstrates the issue. In the meantime, we will roll back on.js to version 1.9.0.

Attachments (3)

Test_SL_menu_bug.html (2.6 KB) - added by neville1355 5 years ago.
Standalone test case
Test_SL_menu_bug_potential_fix.html (3.0 KB) - added by neville1355 5 years ago.
Stubbed has("event-focusin") to be true before "dojo/on" has a chance to add its check. Seems to fix the issue.
Test_SL_menu_bug_potential_fix_2.html (3.5 KB) - added by neville1355 5 years ago.
Use aspect to avoid calling _onFocusNode/_onTouchNode if the originating node is my silverlight node

Download all attachments as: .zip

Change History (15)

Changed 5 years ago by neville1355

Attachment: Test_SL_menu_bug.html added

Standalone test case

comment:1 Changed 5 years ago by bill

Milestone: tbd1.9.3
Owner: set to Colin Snover
Status: newassigned
Summary: Cannot select drop down menu items when displaying on top of silverlight (MacOS + Firefox only)[regresssion] Cannot select drop down menu items when displaying on top of silverlight (MacOS + Firefox only)

Colin, that code is from your e245ce5 change, refs #17599.

comment:2 Changed 5 years ago by Colin Snover

Summary: [regresssion] Cannot select drop down menu items when displaying on top of silverlight (MacOS + Firefox only)[regression] Cannot select drop down menu items when displaying on top of silverlight (MacOS + Firefox only)

Well, that doesn’t make any sense, but I’ll look into it.

comment:3 Changed 5 years ago by Colin Snover

I can easily reproduce the OP’s issue with the implicated code completely commented out, so it’s not looking like it is related at all to e245ce5.

comment:4 Changed 5 years ago by Colin Snover

In fact I can reproduce the issue in Dojo 1.9.0 and 1.9.1 too. If this has worked at some point in the past, I suspect that this is a Firefox regression, not a Dojo regression.

comment:5 Changed 5 years ago by Colin Snover

Owner: changed from Colin Snover to bill

It does work in Dojo 1.8.2, so it looks like a regression between 1.8 and 1.9.

Bisected:

a42b8ed0fc2c297ad36931a2fa028fd000bae266 is the first bad commit
commit a42b8ed0fc2c297ad36931a2fa028fd000bae266
Author: Bill Keese <bill@dojotoolkit.org>
Date:   Mon Mar 25 02:00:51 2013 +0000

    Fix regression from [30957]: evt.target is the normalized way to reference the event target, not evt.srcElement.  Fixes exception on firefox.  Refs #13341 !strict.
    
    git-svn-id: http://svn.dojotoolkit.org/src/dijit/trunk@30994 560b804f-0ae3-0310-86f3-f6aa0a117693

:100644 100644 cc7258f25b2d3feb2ea3f3d3e651852659e194b9 86ec8b65678aca48965f5c3bf88a2b01c277dc90 M	focus.js

It’s all yours :)

comment:6 Changed 5 years ago by neville1355

Thanks for the quick responses all :)

You're right in that changing the library to 1.9.0 on my test page doesn't appear to fix the issue, I misdiagnosed that.

Please let me know if you find anything else for this bug. It's caused a fairly major regression as users cannot navigate our application in this environment anymore.

comment:7 Changed 5 years ago by neville1355

It looks like forcing the has('event-focusin') check to be true before dojo/on is required will fix the issue.

I attached my "fix" to the solution as a separate attachment. Obviously this is incomplete as I'm simply stubbing this to always return true.

I did this because it looked like the focusin event on the body tag within focus.js was causing the drop down to be closed before the menu item was actually clicked.

Changed 5 years ago by neville1355

Stubbed has("event-focusin") to be true before "dojo/on" has a chance to add its check. Seems to fix the issue.

comment:8 Changed 5 years ago by Colin Snover

Firefox doesn’t have focusin support so all you’re probably doing is breaking focus code.

comment:9 Changed 5 years ago by neville1355

Is it normal that I see the focusin event fire on firefox on the body tag, then? That appears to be specifically what causes my drop down to hide.

Edit: I see now that on.js coalesces focusin to default to focus if not supported. It still seems like the root of the problem is trying to focus in on the silverlight node from this code, though.

Last edited 5 years ago by neville1355 (previous) (diff)

comment:10 Changed 5 years ago by neville1355

I created a workaround module that aspect's around dijit/focus's _onFocusNode and _onTouchNode. It's not an ideal solution, and is pretty hacky, but it works for us right now. Hopefully when this gets addressed in a future version of dojo we can remove the code I added.

Attached sample of my "fix".

Changed 5 years ago by neville1355

Use aspect to avoid calling _onFocusNode/_onTouchNode if the originating node is my silverlight node

comment:11 Changed 5 years ago by bill

Component: GeneralDijit
Milestone: 1.9.3tbd

Hi neville1355, So, somehow the silverlight node is getting a focus or click event, even though the user is actually clicking on the menu on top of the silverlight node? This is why we use the BackgroundIframe? behind the Menu, but in this case I guess it's not working.

I'm not sure why this used to work, nor am I sure how to fix it. I hope firefox will eventually fix it on their end. I wonder if it's happening for flash etc. too. The problem sounds familiar.

In any case your workaround seems good.

comment:12 Changed 3 years ago by dylan

Milestone: tbd1.12
Resolution: patchwelcome
Status: assignedclosed

Given that silverlight is nearing its end of life, I'm closing as patchwelcome.

Note: See TracTickets for help on using tickets.