WebAIM - Web Accessibility In Mind

E-mail List Archives

Thread: weird focus behavior

for

Number of posts in this thread: 7 (In chronological order)

From: Jonathan Cohn
Date: Fri, Apr 25 2025 5:15PM
Subject: weird focus behavior
No previous message | Next message →

This does not sound like the write behavior on the part of the browser. If this is occurring in Chrome, have you tried Firefox?


> On Apr 25, 2025, at 2:03 PM, Mike Warner via WebAIM-Forum < = EMAIL ADDRESS REMOVED = > wrote:
>
> Well, this is interesting. As I'm testing a website using a keyboard
> without a screen reader, closing a dialog by hitting escape or tabbing to
> and activating a close button, the focus returns to the button that opened
> the dialog. When using JAWS and NVDA, the focus gets lost and goes to the
> body tag. When I have a live expression in the developer console to see the
> active element (document.activeElement), I can see clearly that the active
> element is the body after closing the dialog. That said, after closing the
> dialog, both screen readers announce the dialog opener button and if I do
> nothing else, hitting enter right after closing the dialog will open the
> dialog again. NVDA's focus indicator also shows that the body tag has the
> focus. Hitting the tab key after closing the dialog with NVDA or JAWS
> brings me to the skip menu, which is the first focusable element on the
> page.
>
> Has anyone else encountered this?
>
> Thanks,
> Mike Warner
> Director of IT Services
> MindEdge Learning
>

From: Mike Warner
Date: Fri, Apr 25 2025 12:03PM
Subject: Re: weird focus behavior
← Previous message | Next message →

Well, this is interesting. As I'm testing a website using a keyboard
without a screen reader, closing a dialog by hitting escape or tabbing to
and activating a close button, the focus returns to the button that opened
the dialog. When using JAWS and NVDA, the focus gets lost and goes to the
body tag. When I have a live expression in the developer console to see the
active element (document.activeElement), I can see clearly that the active
element is the body after closing the dialog. That said, after closing the
dialog, both screen readers announce the dialog opener button and if I do
nothing else, hitting enter right after closing the dialog will open the
dialog again. NVDA's focus indicator also shows that the body tag has the
focus. Hitting the tab key after closing the dialog with NVDA or JAWS
brings me to the skip menu, which is the first focusable element on the
page.

Has anyone else encountered this?

Thanks,
Mike Warner
Director of IT Services
MindEdge Learning

From: Steve Green
Date: Fri, Apr 25 2025 11:49PM
Subject: Re: weird focus behavior
← Previous message | Next message →

I have encountered this many times. However, I don't think I have ever been able to find the cause, so I have just reported the behaviour and left it to the developers to figure it out. The weird thing is that it never happens with anything I build myself, and I'm not a developer, just a tester that's learned a bit of coding.

Steve Green
Managing Director
Test Partners Ltd

From: Mark Magennis
Date: Mon, Apr 28 2025 1:06AM
Subject: Re: weird focus behavior
← Previous message | Next message →

Mike,

Whenever I come across something happening after a screen reader interaction with a control that doesn't happen without the screen reader running, I always check what happens using the mouse. Screen readers sometimes fire mouse and pointer events (mouseUp MouseDown, pointerUp, pointerDown, click) when you press the Enter or Space key to activate a control. In your example, the developers may have added tried to fix the keyboard focus behavior by moving focus to the dialog opener button when the Space and Enter keys are used to close the dialog . But they may not be catching the click events that the mouse (and possibly the screen reader) is generating. Worth looking at.

Mark


From: WebAIM-Forum on behalf of Mike Warner via WebAIM-Forum
Sent: Friday, April 25, 2025 19:03
To: WebAIM Discussion List
Cc: Mike Warner
Subject: [EXTERNAL] [WebAIM] weird focus behavior

Well, this is interesting. As I'm testing a website using a keyboard
without a screen reader, closing a dialog by hitting escape or tabbing to
and activating a close button, the focus returns to the button that opened
the dialog. When using JAWS and NVDA, the focus gets lost and goes to the
body tag. When I have a live expression in the developer console to see the
active element (document.activeElement), I can see clearly that the active
element is the body after closing the dialog. That said, after closing the
dialog, both screen readers announce the dialog opener button and if I do
nothing else, hitting enter right after closing the dialog will open the
dialog again. NVDA's focus indicator also shows that the body tag has the
focus. Hitting the tab key after closing the dialog with NVDA or JAWS
brings me to the skip menu, which is the first focusable element on the
page.

Has anyone else encountered this?

Thanks,
Mike Warner
Director of IT Services
MindEdge Learning

From: Nicholas Bromley
Date: Mon, Apr 28 2025 1:14AM
Subject: Re: weird focus behavior
← Previous message | Next message →

Could it be linked to custom event handlers? NVDA/JAWS register button activation as click events. What happens when you track focus in the console after activating the button with a mouse click?


Kind regards,

Nick
---
Nick Bromley
Director & Accessibility Consultant
Red Kite Digital Accessibility Ltd

From: Mike Warner
Date: Tue, Apr 29 2025 12:53PM
Subject: Re: weird focus behavior
← Previous message | Next message →

Thanks for the replies, everyone! I watched the active element in the
console after closing with a mouse and the focus starts at the button that
launched the dialog, but then moves to the body. Interesting. Not sure
why I didn't notice that before. Guess that I wasn't watching the console
like a hawk.

Mike Warner
Director of IT Services
MindEdge Learning


On Mon, Apr 28, 2025 at 12:14 AM Nicholas Bromley < = EMAIL ADDRESS REMOVED = >
wrote:

> Could it be linked to custom event handlers? NVDA/JAWS register button
> activation as click events. What happens when you track focus in the
> console after activating the button with a mouse click?
>
>
> Kind regards,
>
> Nick
> ---
> Nick Bromley
> Director & Accessibility Consultant
> Red Kite Digital Accessibility Ltd
>

From: Jonathan C. Cohn
Date: Wed, Apr 30 2025 7:31PM
Subject: Re: weird focus behavior
← Previous message | No next message

This can be caused by a blur method being called.
Sent from my iPhone

> On Apr 29, 2025, at 2:53 PM, Mike Warner via WebAIM-Forum < = EMAIL ADDRESS REMOVED = > wrote:
>
> Thanks for the replies, everyone! I watched the active element in the
> console after closing with a mouse and the focus starts at the button that
> launched the dialog, but then moves to the body. Interesting. Not sure
> why I didn't notice that before. Guess that I wasn't watching the console
> like a hawk.
>
> Mike Warner
> Director of IT Services
> MindEdge Learning
>
>
>> On Mon, Apr 28, 2025 at 12:14 AM Nicholas Bromley < = EMAIL ADDRESS REMOVED = >
>> wrote:
>>
>> Could it be linked to custom event handlers? NVDA/JAWS register button
>> activation as click events. What happens when you track focus in the
>> console after activating the button with a mouse click?
>>
>>
>> Kind regards,
>>
>> Nick
>> ---
>> Nick Bromley
>> Director & Accessibility Consultant
>> Red Kite Digital Accessibility Ltd
>>