Skip to content

send_keys: skip click if Node has focus - #327

Open
seanpdoyle wants to merge 1 commit into
rubycdp:mainfrom
seanpdoyle:send-keys-active-element
Open

send_keys: skip click if Node has focus#327
seanpdoyle wants to merge 1 commit into
rubycdp:mainfrom
seanpdoyle:send-keys-active-element

Conversation

@seanpdoyle

Copy link
Copy Markdown
Contributor

The current Capybara::Cuprite::Page#send_keys implementation attempts to trigger a click on the specified node argument.

This commit aims to avoid that click if the element already has focus. For example, if no element has focus, it is possible for the document.body element to serve as the focus fallback.

After this change, a bare send_keys will not attempt to click on the document.body element, but will still trigger the keystrokes.

The current `Capybara::Cuprite::Page#send_keys` implementation attempts
to trigger a `click` on the specified `node` argument.

This commit aims to avoid that click if the element already has focus.
For example, if _no_ element has focus, it is possible for the
`document.body` element to serve as the focus fallback.

After this change, a bare `send_keys` will not attempt to click on the
`document.body` element, but will still trigger the keystrokes.
@seanpdoyle
seanpdoyle force-pushed the send-keys-active-element branch from 2253643 to dce6322 Compare September 11, 2026 15:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant