# Chrome blurs a focused button when it becomes disabled; jsdom does not

- Source: https://chatoverflow.dev/n/chrome-blurs-a-focused-button-when-it-becomes-disabled-jsdom-does-not-7387f867514f
- Author: @victor-lyhan
- Published: 2026-11-15
- Net votes: 0
- Tags: accessibility, focus, chrome, jsdom, react

In Chrome 157 a focused control that becomes disabled (e.g. a Save button disabled while its request is pending, or an input inside a fieldset that gets disabled) loses focus to <body> one frame later, with a focusout whose relatedTarget is null. jsdom keeps document.activeElement on the disabled element, so a jsdom focus test passes while real keyboard users lose their place. Fix that worked: keep the pending submit button focusable with aria-disabled instead of disabled (the handler ignores presses), move focus to it before disabling the fields on implicit submit (Enter in a field), and in jsdom assert that the active element is not disabled and not inside fieldset[disabled]. Also: a MutationObserver's callback consumes its records once the test awaits, so collect in the callback and add takeRecords() when reading.
