You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Focus is lost after closing accessible view #188822
accessibilityKeyboard, mouse, ARIA, vision, screen readers (non-specific) issuesbugIssue identified by VS Code Team member as probable bugcandidateIssue identified as probable candidate for fixing in the next releaseverifiedVerification succeeded
It seems like focus just goes to the 'body' element and I have to tab to get focus back to where I was before. I'd expect it to preserve focus in the same context, same as the command palette.
To properly fix this, we would need to trap the element that's focused before the hover is shown - since by the time the accessible view code is reached, the focus element is the hover itself and there's no way currently to get that from the context view service (for non-editor hovers)
In the meantime, i'm going to see if we can focus the hover - at least from there, escaping will return the focus to the correct element
EDIT: that's not possible atm for non editor hovers
That doesn't work because that element is hidden (it's a context view) on blur when the accessible buffer is opened. So I can call focus on it, but it's not visible and even if it were, wouldn't be in the right spot. we'd have to somehow save the args passed into showContextView and invoke that. seems really messy, thus need to defer and rethink
The hover goes away for me, the best thing would be to prevent the hover from hiding until the a11y view is gone imo. We could fix this by adding lockHover and unlockHover which would prevent it from hiding, then using them in HoverAccessibleViewContribution. Make sure the hover is focused before calling unlockHover.
Oh, this is happening partly because options.trapFocus is not set for the initial showHover call, so _lastFocusedElementBeforeOpen is undefined.
If that were fixed, then it would just be a matter of passing in skipLastFocusedUpdate to showHover from showAndFocusLastHover such that it doesn't override the element that was set on the initial show call.
See in the below that when I close the hover via escape, the list item isn't focused. (regardless of the accessible view this is how it was working)
accessibilityKeyboard, mouse, ARIA, vision, screen readers (non-specific) issuesbugIssue identified by VS Code Team member as probable bugcandidateIssue identified as probable candidate for fixing in the next releaseverifiedVerification succeeded
Activity
meganrogge commentedon Jul 26, 2023
To properly fix this, we would need to trap the element that's focused before the hover is shown - since by the time the accessible view code is reached, the focus element is the hover itself and there's no way currently to get that from the context view service (for non-editor hovers)
In the meantime, i'm going to see if we can focus the hover - at least from there, escaping will return the focus to the correct element
EDIT: that's not possible atm for non editor hovers
meganrogge commentedon Jul 26, 2023
Daniel Imms (@Tyriar) without a big refactor, can you think of a way to get the element that was focused before the hover opened?
fix part of #188822
roblourens commentedon Jul 26, 2023
Can you just grab
document.activeElementbefore showing the accessible view? That's probably what the command palette doesmeganrogge commentedon Jul 26, 2023
thanks for the idea. that's what I tried and it didn't work because, as mentioned above, the active element is the hover.
roblourens commentedon Jul 26, 2023
Right but I thought that you would want to restore focus to the hover
meganrogge commentedon Jul 26, 2023
That doesn't work because that element is hidden (it's a context view) on blur when the accessible buffer is opened. So I can call
focuson it, but it's not visible and even if it were, wouldn't be in the right spot. we'd have to somehow save the args passed intoshowContextViewand invoke that. seems really messy, thus need to defer and rethinkroblourens commentedon Jul 26, 2023
It doesn't get hidden for me.
But yeah maybe that's not a guarantee
Tyriar commentedon Jul 27, 2023
The hover goes away for me, the best thing would be to prevent the hover from hiding until the a11y view is gone imo. We could fix this by adding
lockHoverandunlockHoverwhich would prevent it from hiding, then using them inHoverAccessibleViewContribution. Make sure the hover is focused before callingunlockHover.meganrogge commentedon Jul 27, 2023
The hover is getting disposed of rather than hidden
Tyriar commentedon Jul 27, 2023
Megan Rogge (@meganrogge) mouse out shouldn't be happening by just hitting alt+f1? This is what I mean:
IHoverService.lockHover(oraquireLock(): IDisposable?)IHoverService.unlockHover17 remaining items
Tyriar commentedon Jul 28, 2023
Megan Rogge (@meganrogge) we don't handle
_lastFocusedElementBeforeOpencorrectly in this case:vscode/src/vs/workbench/services/hover/browser/hoverService.ts
Line 28 in 9b81a0d
meganrogge commentedon Jul 28, 2023
Oh, this is happening partly because
options.trapFocusis not set for the initialshowHovercall, so_lastFocusedElementBeforeOpenis undefined.If that were fixed, then it would just be a matter of passing in
skipLastFocusedUpdatetoshowHoverfromshowAndFocusLastHoversuch that it doesn't override the element that was set on the initialshowcall.See in the below that when I close the hover via escape, the list item isn't focused. (regardless of the accessible view this is how it was working)
trap.mov
meganrogge commentedon Jul 28, 2023
I think we always want to
trapFocusfor screen reader users, correct Daniel Imms (@Tyriar) ? not sure why this hasn't been reported as bug before.fix #188822