Skip to content
This repository has been archived by the owner on Jul 14, 2020. It is now read-only.

Add isFocused getter #64

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add isFocused getter #64

wants to merge 1 commit into from

Conversation

cherewaty
Copy link
Contributor

@cherewaty cherewaty commented Jul 3, 2019

Purpose

Testing if an element has focus with is(':focus') can be very frustrating in a local environment. If a user happens to click away from the browser window while they're running a test suite, assertions using is(':focus') will fail.

Meant to address https://github.com/bigtestjs/interactor/issues/62

Approach

Introduce isFocused() that matches on document.activeElement under the hood instead of the :focus pseudo class.

Next steps

Will need a minor release and updates to https://github.com/bigtestjs/bigtestjs.io.

@cherewaty cherewaty requested review from taras and cowboyd July 3, 2019 17:53
Copy link
Contributor

@cowboyd cowboyd left a comment

Choose a reason for hiding this comment

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

A couple of questions:

  • Should this be on every interactor since every interactor ultimately corresponds to an element?
  • Wondering if there should be a containsFocus or hasFocus which matches if the element is, or has a child, which is the activeElement

tests/interactions/is-focused.test.js Outdated Show resolved Hide resolved
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants