Focus in XBL handlers in Firefox 3.6

Most people can safely ignore this post for fear of melting your brains. It’s only here to help people who stumble across the same problem I did, and go googling for the terms I’ve put in the post title.

For a while now Gecko has supported a non-standard CSS extension called “-moz-user-focus“. The main use of this (at least in my code) seemed to be to prevent particular XUL elements from being focusable by setting it to “ignore”.

When I recently upgraded to Firefox 3.6 I found that the focus handler in my XBL widgets was no longer getting called – with the result that I couldn’t even focus them using $(“objectName”).focus() in Firebug. It would appear that the default state for XBL-bound elements has changed from focusable to non-focusable.

The fix for this is simply to add “-moz-user-focus: normal” to the CSS styling of your XBL-bound element. It works whether added directly to a style attribute or in a referenced CSS file. With this in place my focus handler now fires as it used to, and the software works as expected once again.