Skip to content

Modal breaks focus #266

@wichert

Description

@wichert

While investigating euphorie/Euphorie#72 I found an interesting bug: the modal pattern is breaking the autofocus pattern. What happens is this:

  1. new HTML is injected
  2. the browser notices the autofocus attribute on an element and correctly gives that the focus
  3. injection triggers the patterns-injected event, which causes the registry to scan
  4. the registry invokes the autofocus pattern, which sets the focus again according to its own rules
  5. next the modal pattern is invoked, which wraps its content in a div.panel-content

The DOM manipulation at the last step causes the input element to be removed and reinserted at a different place in the DOM, and the focus is lost at that point and reset to document.body.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions