This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 23585 - FKA: when document.activeElement is hidden, it retains its status as document.activeElement, and therefore intercepts keyboard events as the event target
Summary: FKA: when document.activeElement is hidden, it retains its status as document...
Status: RESOLVED FIXED
Alias: None
Product: HTML WG
Classification: Unclassified
Component: HTML5 spec (show other bugs)
Version: unspecified
Hardware: All All
: P2 editorial
Target Milestone: ---
Assignee: This bug has no owner yet - up for the taking
QA Contact: HTML WG Bugzilla archive list
URL:
Whiteboard:
Keywords: a11y, a11ytf
Depends on:
Blocks:
 
Reported: 2013-10-21 17:34 UTC by James Craig
Modified: 2015-06-17 04:16 UTC (History)
7 users (show)

See Also:


Attachments
test case demonstrating bug (tested in WebKit) (1.67 KB, text/html)
2013-10-21 17:34 UTC, James Craig
Details

Description James Craig 2013-10-21 17:34:03 UTC
Created attachment 1410 [details]
test case demonstrating bug (tested in WebKit)

Full Keyboard Access (FKA): when document.activeElement is hidden, it retains its status as document.activeElement, and therefore intercepts keyboard events as the event target.

Load attached test case and follow the instructions. It doesn't make sense that a hidden, unfocusable, unrendered element would be retained as document.activeElement, and therefore be an acceptable event target. This is either a spec bug or a browser bug.
Comment 1 Robin Berjon 2013-10-22 09:25:08 UTC
(In reply to James Craig from comment #0)
> Created attachment 1410 [details]
> test case demonstrating bug (tested in WebKit)
> 
> Full Keyboard Access (FKA): when document.activeElement is hidden, it
> retains its status as document.activeElement, and therefore intercepts
> keyboard events as the event target.
> 
> Load attached test case and follow the instructions. It doesn't make sense
> that a hidden, unfocusable, unrendered element would be retained as
> document.activeElement, and therefore be an acceptable event target. This is
> either a spec bug or a browser bug.

I am not so sure that it's a bug. At least, it's a trick I've used before. The use case is this: you wish to expose a way of editing something that is like text, but not rendered at all like an input (notably, the text itself isn't rendered that way at all). So you give focus to a hidden input and render its content whenever it gets a keyboard event.

I'm not sure that's great for A11Y or that it's the best implementation strategy overall. I'm just pointing out that if it's something that I felt the need to do for a project at some point, I might not be the only one.
Comment 2 James Craig 2013-10-22 19:00:27 UTC
That sounds like a hack to me, but either way, your use case can still be achieved by setting the input's opacity to 0 or positioning it offscreen. However, hidden (and display:none) elements are not rendered in any modality and should therefore not be the document.activeElement or receive keyboard events.
Comment 3 James Craig 2013-11-20 00:46:26 UTC
Hixie says this is resolved in the WHATWG spec:

"An element is focusable if [...] The element is [...] being rendered [...]. When an element that is focused stops being a focusable element [...] the user agent should synchronously run the unfocusing steps for the affected element only."
Comment 4 steve faulkner 2015-06-12 14:51:09 UTC
reflect WHATWG resolution