alphagov / govuk_frontend_toolkit

❗️GOV.UK Frontend Toolkit is deprecated, and will only receive major bug fixes and security patches.
MIT License
403 stars 107 forks source link

Trigger focus-on-click for Firefox [DISCUSS BEFORE MERGE] #358

Closed robinwhittleton closed 7 years ago

robinwhittleton commented 7 years ago

When a user clicks on an unselected radio button in Chrome it’ll fire two events: click and either focus or focusin depending on delegation status. In Firefox only the click event fires. Tabbing through the fields triggers the focus events properly in both browsers.

We’re relying on the focus/focusin events to set the focused class that the yellow outline hooks onto. If we want consistency in this visual behaviour between browsers we either need to find some other way of defining the class, or to trigger the focus state on click dynamically. This commit does the second.

I think Firefox is technically in the wrong here according to the DOM 3 Events spec. At the end of the current click event section is this sentence:

If the event target is focusable, the default action MUST be to give that element document focus.

I’ll file a bug.

robinwhittleton commented 7 years ago

Bug filed: https://bugzilla.mozilla.org/show_bug.cgi?id=1322692

robinwhittleton commented 7 years ago

Firefox bug closed as INVALID:

This is correct behaviour. Radio buttons do not get focused when clicked on Mac.

robinwhittleton commented 7 years ago

As I just wrote, I’m not sure this is the right thing to be doing any more. Probably better to close this PR rather than merge.