Repository navigation
Conversation
commit: |
cowboyd
force-pushed
the
dom-is-connected
branch
from
December 1, 2026 18:17
3c7a113 to
539291a
Compare
cowboyd
marked this pull request as ready for review
December 1, 2026 19:14
cowboyd
force-pushed
the
dom-is-connected
branch
from
December 2, 2026 14:58
539291a to
ca61096
Compare
cowboyd
force-pushed
the
dom-is-connected
branch
from
December 2, 2026 17:26
ca61096 to
cfbd554
Compare
cowboyd
marked this pull request as draft
December 2, 2026 22:22
cowboyd
force-pushed
the
dom-is-connected
branch
3 times, most recently
from
December 3, 2026 19:31
89c8fa4 to
4b3d8e8
Compare
cowboyd
force-pushed
the
dom-focus
branch
2 times, most recently
from
December 3, 2026 21:25
8863192 to
e510812
Compare
cowboyd
marked this pull request as ready for review
December 3, 2026 21:25
natemoo-re
reviewed
Dec 5, 2026
Comment on lines
+1049
to
+1102
| function setActiveElement(document: Document, element: Element | null): void { | ||
| if (element === null) { | ||
| focii.delete(document); | ||
| } else { | ||
| focii.set(document, element); | ||
| } | ||
| } | ||
|
|
||
| function getActiveElement(document: Document): Element | null { | ||
| return focii.get(document) ?? null; | ||
| } | ||
|
|
||
| function transitionActiveElement(document: Document, to: Element | null): void { | ||
| const current = getActiveElement(document); | ||
| if (to === current) { | ||
| return; | ||
| } | ||
|
|
||
| setActiveElement(document, null); | ||
|
|
||
| if (current !== null) { | ||
| dispatch(current, { | ||
| event: new FocusEvent('blur', { | ||
| relatedTarget: to, | ||
| }), | ||
| isTrusted: true, | ||
| }); | ||
|
|
||
| dispatch(current, { | ||
| event: new FocusEvent('focusout', { | ||
| relatedTarget: to, | ||
| }), | ||
| isTrusted: true, | ||
| }); | ||
| } | ||
|
|
||
| setActiveElement(document, to); | ||
|
|
||
| if (to !== null) { | ||
| dispatch(to, { | ||
| event: new FocusEvent('focus', { | ||
| relatedTarget: current, | ||
| }), | ||
| isTrusted: true, | ||
| }); | ||
| dispatch(to, { | ||
| event: new FocusEvent('focusin', { | ||
| relatedTarget: current, | ||
| }), | ||
| isTrusted: true, | ||
| }); | ||
| } | ||
| } | ||
|
|
Member
There was a problem hiding this comment.
Might be nice to wrap this up in a FocusManager state machine? could give us a good extension point for implementing tab behavior
Contributor
Author
There was a problem hiding this comment.
@natemoo-re How about we do that with this one #127
Then we'll have all the pieces and we can put them together in a separate module.
dreyfus92
reviewed
Dec 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Adds focus(), blur(), activeElement, and focus events. Removing a focused subtree clears focus without firing blur.
Type of change
Checklist
pnpm test)pnpm format)AI-generated code disclosure