Open Bug 1727964 Opened 4 years ago Updated 1 year ago

`HTMLElement.blur()` can not cancel all the focus in sub tree

Categories

(Core :: DOM: UI Events & Focus Handling, defect, P3)

Firefox 93
defect

Tracking

()

UNCONFIRMED

People

(Reporter: 709922234, Unassigned)

Details

(Whiteboard: [domcore-bugbash-triaged])

Attachments

(1 file)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:93.0) Gecko/20100101 Firefox/93.0

Steps to reproduce:

visit: https://codepen.io/mantou132/pen/PomMMbj

document.body.innerHTML = `
  <my-ele>
    <div tabindex=1>foucesable</div>
  </my-ele>
`
document.querySelector('div').focus();
document.querySelector('my-ele').blur();
document.body.append(`current active element: ${document.activeElement.tagName}`);

Actual results:

current active element: DIV

Expected results:

current active element: BODY

Component: Untriaged → DOM: Core & HTML
Product: Firefox → Core
Component: DOM: Core & HTML → DOM: UI Events & Focus Handling

Firefox 71 behaves the same and Chome and Edge also behave the same.
However, Safari reset the focus to Body.

Severity: -- → S3
Priority: -- → P3

In custom elements, it is useful to be able to cancel the focus of the sub tree, for example:

<my-form>
    #shadow-root
    <form-item>
      #shadow-root
        <input>
    <form-item>
<my-form>

Chrome changed their behavior that they reset the focus to Body as Safari. We still need to see what the spec says.

Whiteboard: [domcore-bugbash-triaged]
Flags: needinfo?(sefeng)
Attached image image.png

left: Chrome, right: Firefox

Clear my NI given I won't be able to work on this

Flags: needinfo?(sefeng)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: