Opened 12 years ago

Last modified 5 years ago

#11226 new defect

Uncaught exception in dijit/focus.js if current focus on input with "display: none"

Reported by: linuxbox Owned by:
Priority: high Milestone: 1.15
Component: Dijit Version: 1.4.1
Keywords: focus hidden Cc:
Blocked By: Blocking:


I have problem when i hide focused input with "display: none" style. Small example:

I have span with styled text. When i click on the span it hides and text input is shown instead. I can write some new values and when i click outside the input it gets hidden and span with styled text is shown again. The problem is when i click on element with binded dijit.Menu after hiding the input - i get this error in Firefox 3.6.3 (Chromium 6.0.414 and Opera 10.53 no problem):

uncaught exception: 
[Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIDOMNSHTMLInputElement.selectionStart]"
nsresult: "0x80004005 (NS_ERROR_FAILURE)"
location: "JS frame :: http://dev1:8000/dojo/dijit/_base/focus.js :: anonymous :: line 50" data: no]

It looks like there still focus on hidden input. A found quick solution for me:

< 						if(tg == "textarea" ||
< 								(tg == "input" && (!cf.type || cf.type.toLowerCase() == "text"))){
> 						if( != "none" &&
> 								(tg == "textarea" ||
> 								(tg == "input" && (!cf.type || cf.type.toLowerCase() == "text")))){

I down know if i'm doing something wrong, but i think i shouldn't get any uncaught exception. focus.js in dojo 1.4.3 is identical so i suppose there will be same problem.

Change History (3)

comment:1 Changed 12 years ago by bill

Milestone: tbdfuture

Yeah, FF (and maybe other browsers, I forget) throw a fit when you hide the element with focus. We had to jump through hoops to get InlineEditBox working around issues like that. Although I guess this is a little different since it's an issue with bookmarks.

Your code change to focus.js will fix the problem where the <input> is display:none, but not when an ancestor of the <input> is display:none. I'm also not sure if there's an issue of the <input> or an ancestor is visibility:hidden, etc.

Maybe it's best to just put that code in a try/catch.

comment:2 Changed 6 years ago by dylan

Milestone: future1.12

Probably worth investigating and fixing for 1.12.

comment:3 Changed 5 years ago by dylan

Milestone: 1.131.15

Ticket planning... move current 1.13 tickets out to 1.15 to make it easier to move tickets into the 1.13 milestone.

Note: See TracTickets for help on using tickets.