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 23543 - Add an ignorefocus attribute to iframe
Summary: Add an ignorefocus attribute to iframe
Status: RESOLVED NEEDSINFO
Alias: None
Product: WHATWG
Classification: Unclassified
Component: HTML (show other bugs)
Version: unspecified
Hardware: All All
: P2 normal
Target Milestone: Unsorted
Assignee: Ian 'Hixie' Hickson
QA Contact: contributor
URL:
Whiteboard: blocked awaiting response from kchen@...
Keywords:
Depends on:
Blocks:
 
Reported: 2013-10-17 08:58 UTC by Kan-Ru Chen (陳侃如) [:kanru]
Modified: 2015-08-04 09:33 UTC (History)
4 users (show)

See Also:


Attachments

Description Kan-Ru Chen (陳侃如) [:kanru] 2013-10-17 08:58:23 UTC
In order to create a reuseable component using iframe, sometimes we need to make the iframe unfocusable. For example if we want to create a on screen virtual keyboard the resides in a iframe, it should not take the focus from the input field while it still needs to receive the touch events, this rules out the pointer-events:none css style.

The ignorefocus attribute should explicitly mark the iframe unfocusable, no focus transition will happen. If it is set after the iframe already has focus then the focus remain as is, but the iframe can't take focus again if it lose it.
Comment 1 Ian 'Hixie' Hickson 2013-10-18 18:31:57 UTC
Should this prevent controls in the iframe from being focused also?
Comment 2 Olli Pettay 2013-10-18 18:53:24 UTC
Yes, the idea is that tabbing or mouse/pointer wouldn't focus anything in the iframe.
Perhaps the attribute could be ignoreuserfocus, if we still want to
.focus() to work
Comment 3 Ian 'Hixie' Hickson 2013-10-21 21:41:16 UTC
How would keyboard-only users use pages that used this?
Comment 4 Kan-Ru Chen (陳侃如) [:kanru] 2013-10-22 05:11:48 UTC
(In reply to Ian 'Hixie' Hickson from comment #3)
> How would keyboard-only users use pages that used this?

They won't be able to access that iframe. Other elements are focused normally.
Comment 5 Ian 'Hixie' Hickson 2013-10-22 21:35:50 UTC
Isn't that a problem...?
Comment 6 Olli Pettay 2013-10-22 21:49:59 UTC
Well, in this particular use case, keyboard-only users wouldn't need the
whole thing since they can just use a keyboard.
This is more for keyboard-less users, at least the use case is.
Also, I'd expect this to work so that user focus is ignored.
The page itself could call .focus() or some such, which means the
page inside ignorefocus would be just accessible to keyboard-only user
as for touch-only user, if wanted.
Comment 7 Ian 'Hixie' Hickson 2013-10-23 19:02:23 UTC
If the goal is to make pointer events not transfer focus (but to leave the controls in, e.g., the tab order), since is probably more an issue for something like CSS. Something like pointer-events:no-focus or something.
Comment 8 Olli Pettay 2013-10-23 19:03:25 UTC
no tab order either, when looking at the outside of the iframe.
Comment 9 Ian 'Hixie' Hickson 2013-11-18 23:20:49 UTC
Preventing users from focusing a frame entirely seems a bit dodgy.
Comment 10 Ian 'Hixie' Hickson 2013-12-11 21:42:48 UTC
Would putting this in the iframe be insufficient?:

   <body onmousedown="return false">
Comment 11 Kan-Ru Chen (陳侃如) [:kanru] 2013-12-13 02:42:34 UTC
(In reply to Ian 'Hixie' Hickson from comment #10)
> Would putting this in the iframe be insufficient?:
> 
>    <body onmousedown="return false">

That would require all of this kind of content to include this snippet, which maybe not so bad... And it does not work with remote iframes (the frame's page is loaded in a separate content process). The parent frame couldn't block on the iframe's event handler execution.
Comment 12 Ian 'Hixie' Hickson 2013-12-14 02:05:31 UTC
(In reply to Kan-Ru Chen (陳侃如) [:kanru] from comment #11)
> (In reply to Ian 'Hixie' Hickson from comment #10)
> > Would putting this in the iframe be insufficient?:
> > 
> >    <body onmousedown="return false">
> 
> That would require all of this kind of content to include this snippet,
> which maybe not so bad...

Well, presumably the content of the iframe is in a better position to know if it's good to not focus things than the container is, right? (I'm still not 100% clear on the use case, but if it's an on-screen keyboard, one could imagine that it might sometimes want to show a settings dialog where focus _is_ to be allowed, e.g. so that someone can type some text in an "add to dictionary" dialog.)

This snippet isn't particularly longer than having an ignorefocus="" attribute on the <iframe>, either.


> And it does not work with remote iframes (the frame's page is loaded in a
> separate content process).

Can you elaborate on this? Why would it not work if the iframe was remote?


> The parent frame couldn't block on the iframe's event handler execution.

The snippet would have to go in the embedded frame, not on the <iframe> element.
Comment 13 Kan-Ru Chen (陳侃如) [:kanru] 2013-12-15 05:42:59 UTC
(In reply to Ian 'Hixie' Hickson from comment #12)
> (In reply to Kan-Ru Chen (陳侃如) [:kanru] from comment #11)
> > (In reply to Ian 'Hixie' Hickson from comment #10)
> > > Would putting this in the iframe be insufficient?:
> > > 
> > >    <body onmousedown="return false">
> > 
> > That would require all of this kind of content to include this snippet,
> > which maybe not so bad...
> 
> Well, presumably the content of the iframe is in a better position to know
> if it's good to not focus things than the container is, right? (I'm still
> not 100% clear on the use case, but if it's an on-screen keyboard, one could
> imagine that it might sometimes want to show a settings dialog where focus
> _is_ to be allowed, e.g. so that someone can type some text in an "add to
> dictionary" dialog.)
> 
> This snippet isn't particularly longer than having an ignorefocus=""
> attribute on the <iframe>, either.

Agree. But using the ignorefocus attribute the iframe owner could inforce the rule.
 
> > And it does not work with remote iframes (the frame's page is loaded in a
> > separate content process).
> 
> Can you elaborate on this? Why would it not work if the iframe was remote?

Because if the iframe was remote then the event handler will be run asynchronously. Otherwise if the on-screen keyboard is slow to responce, it could block the owner content. 
 
> > The parent frame couldn't block on the iframe's event handler execution.
> 
> The snippet would have to go in the embedded frame, not on the <iframe>
> element.
Comment 14 Ian 'Hixie' Hickson 2013-12-16 22:46:13 UTC
I don't understand why it matters if it is async or not. Can you elaborate? All that matters if that the focus isn't taken when the user interacts with the focusable controls using a non-keyboard input device, right?