Skip to content

Conversation

@mogstad
Copy link
Contributor

@mogstad mogstad commented Oct 21, 2025

Convinient helper that resolves when a target receives focus. Useful for verifying keyboard navigation handling and default focus.

Uses the pull based waitUntil helper to support the element not being in the DOM when invoking the helper.

Alternatives without this helper is asserting document.activeElement is the target. It usually work, but there are cases it focus may happne async. The element isn't in view yet.

Copy link
Collaborator

@NullVoxPopuli NullVoxPopuli left a comment

Choose a reason for hiding this comment

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

looks good to me -- want to add docs and all that?

@mogstad
Copy link
Contributor Author

mogstad commented Oct 21, 2025

Will do!

Convinient helper that resolves when a target receives focus. Useful for
verifying keyboard navigation handling and default focus.

Uses the pull based waitUntil helper to support the element not being in
the DOM when invoking the helper.

Alternatives without this helper is asserting `document.activeElement` is
the target. It usually work, but there are cases it focus may happne
async. The element isn't in view yet.
@NullVoxPopuli
Copy link
Collaborator

I'm going to ignore the types (next) failure on this PR -- it's unrelated to the work here and more about our pre-existing tsconfig.


if (!timeoutMessage) {
const description = getDescription(target);
timeoutMessage = `waitForFocus timed out waiting for selector "${description}"`;
Copy link
Collaborator

Choose a reason for hiding this comment

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

thanks for including the description here!

@NullVoxPopuli NullVoxPopuli changed the title Propose waitForFocus DOM Helper waitForFocus DOM Helper Oct 22, 2025
@NullVoxPopuli NullVoxPopuli merged commit 294eba3 into emberjs:master Oct 22, 2025
24 of 25 checks passed
@github-actions github-actions bot mentioned this pull request Oct 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants