Skip to content

Focus events do not always fire with pointer input when a Display is in an iframe #1771

@jessegreenberg

Description

@jessegreenberg

Found in phetsims/vector-addition#442. A Display in an iframe can fail to receive focus events. If the parent window is active (has focus), focus cannot be set programmatically in the iframe Display and focus events are not dispatched at all.

To reproduce the problem

  • Run a PhET simulation in an iframe.
  • Click or focus something in the parent window (outside of the iframe Display).
  • Now observe that scripted calls to node.focus() do nothing, and event listeners on focus events never fire.

We will have to be careful with this. We do not want to steal focus from the parent window, that will annoy the parent application and make it more difficult for people to embed scenery Displays in iframes. However, it seems fair to move focus into the iframe window when it receives input. And I am worried about problems that could occur when we do not consistently get focus events.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions