Skip to content

Add focus pseudo-class selectors and Element.matches - #128

Draft
cowboyd wants to merge 1 commit into
dom-tab-navigationfrom
dom-focus-selectors
Draft

cowboyd wants to merge 1 commit into
dom-tab-navigationfrom
dom-focus-selectors

Conversation

@cowboyd

@cowboyd cowboyd commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds :focus, :focus-within, and Element.matches(). Under the current keyboard-only policy, :focus-visible matches focused elements.

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

@cowboyd
cowboyd force-pushed the dom-tab-navigation branch from b523ee5 to 9e56c94 Compare December 1, 2026 18:08
@cowboyd
cowboyd force-pushed the dom-focus-selectors branch from 3fe9ed8 to 96e15fc Compare December 1, 2026 18:08
@pkg-pr-new

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

Copy link
Copy Markdown

commit: c307dce

@cowboyd
cowboyd force-pushed the dom-focus-selectors branch from 96e15fc to e82d541 Compare December 1, 2026 18:17
@cowboyd
cowboyd force-pushed the dom-tab-navigation branch from 9e56c94 to daa27f3 Compare December 1, 2026 18:17
@cowboyd
cowboyd added this pull request to stack #114 December 1, 2026 18:53
@cowboyd
cowboyd force-pushed the dom-focus-selectors branch from e82d541 to 278a76c Compare December 1, 2026 18:58
@cowboyd
cowboyd force-pushed the dom-tab-navigation branch 2 times, most recently from 3ca42c7 to 1d7926d Compare December 1, 2026 19:40
@cowboyd
cowboyd force-pushed the dom-focus-selectors branch from 278a76c to bb7ca6e Compare December 1, 2026 19:40
@cowboyd
cowboyd marked this pull request as ready for review December 1, 2026 19:54
@cowboyd
cowboyd force-pushed the dom-focus-selectors branch 2 times, most recently from c307dce to d8b3f74 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

@natemoo-re natemoo-re 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.

selector side looks good! one thing my agent caught before we have styles based on these pseudos...

focus changes don't notify(). setActiveElement just writes to the focii WeakMap, so once the UA sheet (#138) or author styles have a rule like fieldset:focus-within { … } (spec), calling .focus() won't re-render. with replay from #143 it gets even worse, since the :focus-within ancestor isn't in changes and its subtree gets replayed stale.

wonder if transitionActiveElement should just notify the old and new active elements? the ancestor walk in RenderApi.request already covers :focus-within. totally fine as a follow-up—sibling combinators and attribute selectors have the same style invalidation gap which we'll need to fix

@cowboyd

cowboyd commented Dec 3, 2026

Copy link
Copy Markdown
Contributor Author

selector side looks good! one thing my agent caught before we have styles based on these pseudos...

focus changes don't notify(). setActiveElement just writes to the focii WeakMap, so once the UA sheet (#138) or author styles have a rule like fieldset:focus-within { … } (spec), calling .focus() won't re-render. with replay from #143 it gets even worse, since the :focus-within ancestor isn't in changes and its subtree gets replayed stale.

wonder if transitionActiveElement should just notify the old and new active elements? the ancestor walk in RenderApi.request already covers :focus-within. totally fine as a follow-up—sibling combinators and attribute selectors have the same style invalidation gap which we'll need to fix

This is a great catch! We can factor this in when I re-habilitate the other PRs in the focus/input/edit stack

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.

2 participants