Skip to content

Prevent focus inside inert subtrees - #119

Merged
cowboyd merged 2 commits into
mainfrom
dom-inert
Dec 6, 2026
Merged

cowboyd merged 2 commits into
mainfrom
dom-inert

Conversation

@cowboyd

@cowboyd cowboyd commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Reflects HTMLElement.inert and prevents elements inside inert subtrees from receiving focus.

Type of change

  • Bug fix
  • Feature
  • Refactor (no behavior change)
  • Documentation
  • Performance improvement
  • Tests
  • Chore (dependencies, CI, tooling)

Checklist

  • All tests pass (pnpm test)
  • Files are formatted (pnpm format)
  • I have added/updated tests for my changes (if applicable)
  • I have added a changeset

AI-generated code disclosure

  • This PR includes AI-generated code

@pkg-pr-new

pkg-pr-new Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

commit: 9cb1422

@cowboyd
cowboyd added this pull request to stack #114 December 1, 2026 18:03
@cowboyd
cowboyd marked this pull request as ready for review December 1, 2026 19:15
@cowboyd
cowboyd force-pushed the dom-focus branch 2 times, most recently from c8b63d8 to 77fac71 Compare December 2, 2026 17:26
@cowboyd
cowboyd marked this pull request as draft December 2, 2026 22:22
@cowboyd cowboyd added the input focus, keyboard, editing, mouse, anything coming from the release. label Dec 2, 2026
@cowboyd cowboyd added this to the Alpha-1 milestone Dec 2, 2026
@cowboyd
cowboyd removed this pull request from stack #114 December 2, 2026 22:23
@cowboyd
cowboyd force-pushed the dom-focus branch 4 times, most recently from 9c8d7a8 to 1f0081a Compare December 5, 2026 19:13
Base automatically changed from dom-focus to main December 5, 2026 19:28
@cowboyd
cowboyd marked this pull request as ready for review December 5, 2026 19:47

@dreyfus92 dreyfus92 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left a question, but lgtm 👀

Comment thread packages/ui/src/dom.ts
return this.hasAttributeNS(null, 'inert');
}

set inert(value: boolean) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so if the focused element or an ancestor becomes inert, activeElement still points at it. browsers drop focus back to body here, inert/dynamic-inert-on-focused-element.html covers it. follow-up?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice catch!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, We should add it as a follow-up.

@cowboyd
cowboyd merged commit fb7da7b into main Dec 6, 2026
9 checks passed
@cowboyd
cowboyd deleted the dom-inert branch December 6, 2026 01:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

input focus, keyboard, editing, mouse, anything coming from the release.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants