Skip to content

Focus is lost after closing accessible view #188822

Description

@roblourens

Testing #188537

  • Focus on a hover
  • Press alt+f2
  • Press escape

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.

Activity

  1. added
    bug
    accessibility
    on Jul 26, 2023
  2. meganrogge commented on Jul 26, 2023

    @meganrogge
    Collaborator

    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

  3. meganrogge commented on Jul 26, 2023

    @meganrogge
    Collaborator

    Daniel Imms (@Tyriar) without a big refactor, can you think of a way to get the element that was focused before the hover opened?

  4. roblourens commented on Jul 26, 2023

    @roblourens
    MemberAuthor

    Can you just grab document.activeElement before showing the accessible view? That's probably what the command palette does

  5. meganrogge commented on Jul 26, 2023

    @meganrogge
    Collaborator

    thanks for the idea. that's what I tried and it didn't work because, as mentioned above, the active element is the hover.

  6. roblourens commented on Jul 26, 2023

    @roblourens
    MemberAuthor

    Right but I thought that you would want to restore focus to the hover

  7. meganrogge commented on Jul 26, 2023

    @meganrogge
    Collaborator

    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

  8. roblourens commented on Jul 26, 2023

    @roblourens
    MemberAuthor

    It doesn't get hidden for me.

    • Show hover
    • Press alt+f1
    • press escape
    • hover is still there

    But yeah maybe that's not a guarantee

  9. Tyriar commented on Jul 27, 2023

    @Tyriar
    Contributor

    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.

  10. meganrogge commented on Jul 27, 2023

    @meganrogge
    Collaborator

    The hover is getting disposed of rather than hidden

  11. Tyriar commented on Jul 27, 2023

    @Tyriar
    Contributor

    Megan Rogge (@meganrogge) mouse out shouldn't be happening by just hitting alt+f1? This is what I mean:

    1. Show hover (hover with mouse of ctrl+k, ctrl+i)
    2. alt+f1
    3. Call IHoverService.lockHover (or aquireLock(): IDisposable?)
    4. Show a11y view
    5. Escape
    6. Focus hover
    7. Call IHoverService.unlockHover
  12. 17 remaining items

  13. removed
    insiders-released
    on Jul 28, 2023
  14. Tyriar commented on Jul 28, 2023

    @Tyriar
    Contributor

    Megan Rogge (@meganrogge) we don't handle _lastFocusedElementBeforeOpen correctly in this case:

    private _lastFocusedElementBeforeOpen: HTMLElement | undefined;

  15. added
    candidate
    on Jul 28, 2023
  16. meganrogge commented on Jul 28, 2023

    @meganrogge
    Collaborator

    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)

    trap.mov
  17. meganrogge commented on Jul 28, 2023

    @meganrogge
    Collaborator

    I think we always want to trapFocus for screen reader users, correct Daniel Imms (@Tyriar) ? not sure why this hasn't been reported as bug before.

  18. added a commit that references this issue on Jul 28, 2023
    9123c57
  19. added
    unreleased
    on Jul 28, 2023
  20. removed
    unreleased
    on Jul 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

accessibilitybugcandidateverified

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions