Closed Bug 1740989 Opened 1 year ago Closed 3 months ago

Form inputs remain focused when disabled (focus fixup rule not followed)

Categories

(Core :: DOM: UI Events & Focus Handling, defect)

Firefox 94
defect

Tracking

()

RESOLVED FIXED
106 Branch
Tracking Status
firefox106 --- fixed

People

(Reporter: abacabadabacaba, Assigned: emilio)

References

(Blocks 2 open bugs, Regressed 2 open bugs)

Details

Attachments

(3 files)

Steps to reproduce:

Try the following code:

HTML:
<input id=foo>

JavaScript:
foo.focus();
foo.disabled = true;
console.log(document.activeElement);

Actual results:

The value logged is the input element.

Expected results:

According to the HTML specification, the document's body element should have been logged instead. Chromium behaves according to the specification, but Firefox doesn't.

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

Component: Untriaged → Console
Product: Firefox → DevTools
Component: Console → DOM: UI Events & Focus Handling
Product: DevTools → Core
Blocks: 1656849
Severity: -- → S3
Attached file Another test-case.

Chrome seems to implement the fixup rule somewhat inconsistently. It works for disabled, but not for other stuff that affects focusability like visibility or so.

Not even display: none, for that matter.

Assignee: nobody → emilio
Attached file Refined test-case.

It seems Blink implements this at some point after the RAF callbacks but before rendering. Need to check the spec but I think it's about time to fix this.

Flags: needinfo?(emilio)
See Also: → 1787456

This implements the proposal in the linked spec issue, and makes
it nightly-only pending resolution + edits.

Flags: needinfo?(emilio)
Pushed by ealvarez@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/d8f983951128
Implement focus fixup rule. r=smaug

Backed out for causing mochitest-chrome failures on test_modal_prompts.html.

Push with failures

Failure log

Backout link

[task 2022-08-31T21:49:32.358Z] 21:49:32     INFO - TEST-PASS | toolkit/components/prompts/test/test_modal_prompts.html | Checking cancel-button isn't disabled 
[task 2022-08-31T21:49:32.359Z] 21:49:32     INFO - Buffered messages finished
[task 2022-08-31T21:49:32.359Z] 21:49:32     INFO - TEST-UNEXPECTED-FAIL | toolkit/components/prompts/test/test_modal_prompts.html | checking button0 default - got true, expected false
[task 2022-08-31T21:49:32.359Z] 21:49:32     INFO - SimpleTest.is@chrome://mochikit/content/tests/SimpleTest/SimpleTest.js:497:14
[task 2022-08-31T21:49:32.359Z] 21:49:32     INFO - checkPromptState@chrome://mochitests/content/chrome/toolkit/components/prompts/test/prompt_common.js:291:5
[task 2022-08-31T21:49:32.360Z] 21:49:32     INFO - handlePrompt@chrome://mochitests/content/chrome/toolkit/components/prompts/test/prompt_common.js:196:19
[task 2022-08-31T21:49:32.360Z] 21:49:32     INFO - TEST-PASS | toolkit/components/prompts/test/test_modal_prompts.html | checking button1 default 
Flags: needinfo?(emilio)
Flags: needinfo?(emilio)
Pushed by ealvarez@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/81580b85d04c
Implement focus fixup rule. r=smaug
Status: NEW → RESOLVED
Closed: 3 months ago
Resolution: --- → FIXED
Target Milestone: --- → 106 Branch
Blocks: 1788741
Regressions: 1788808
Regressions: 1788908
Regressions: 1788913
Regressions: 1789170
Regressions: 1789427
Regressions: 1792057
You need to log in before you can comment on or make changes to this bug.