Closed Bug 1712587 Opened 5 years ago Closed 5 years ago

focus stays on disabled element which inhibits keypress events

Categories

(Core :: DOM: Events, defect)

Firefox 88
defect

Tracking

()

RESOLVED DUPLICATE of bug 75324

People

(Reporter: ra_hardy, Unassigned)

Details

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:88.0) Gecko/20100101 Firefox/88.0

Steps to reproduce:

https://jsfiddle.net/sLftvywk/2/

Click 'Run'. Type a key on the keyboard

Actual results:

The keypress isn't logged.
Logged output: "Active element:", "HTMLButtonElement"

Expected results:

The keypress is logged.

This works in Chrome. Chrome seems to change the activeElement to be "HTMLBodyElement" when the button is disabled. Firefox keeps the focus on the disabed button, then the keypress events don't fire.

The workaround needed is (after updating the UI state)
if (document.activeElement.disabled) document.activeElement.blur();

The Bugbug bot thinks this bug should belong to the 'Core::DOM: Events' component, and is moving the bug to that component. Please revert this change in case you think the bot is wrong.

Component: Untriaged → DOM: Events
Product: Firefox → Core

Wow. Duplicate of a 5-digit bug.

Status: UNCONFIRMED → RESOLVED
Closed: 5 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.