microsoft / microsoft-ui-xaml

Windows UI Library: the latest Windows 10 native controls and Fluent styles for your applications
MIT License
6.36k stars 678 forks source link

TabView only supports closing tabs with a pointer device #1648

Closed mrlacey closed 1 year ago

mrlacey commented 4 years ago

Describe the bug It is not possible to close a TabViewItem using just the keyboard - likely ALLY issue.

Steps to reproduce the bug

  1. In a blank app, add a TabView control.
  2. Add some TabViewItems to the TabItems collection.
  3. Add a handler for the TabCloseRequested event.
  4. Set a break point in the event handler.
    <winui:TabView
        TabCloseRequested="OnTabCloseRequested">
        <winui:TabView.TabItems>
            <winui:TabViewItem Header="Item 1" />
            <winui:TabViewItem Header="Item 2" />
            <winui:TabViewItem Header="Item 3" />
        </winui:TabView.TabItems>
    </winui:TabView>
  1. Run the app.
  2. Try and close a tab without using a mouse, pen, finger, or other pointing device. i.e. just using keyboard (or a connected controller.)

Expected behavior The break point will never be hit! It should be possible to close a tab without having to use a pointing device. Without this it is not possible to provide a fully accessible experience using this control.

Screenshots button in question is highlighted in the screenshot below image

Version Info

NuGet package version: Microsoft.UI.Xaml 2.2.190917002

Windows 10 version Saw the problem?
Insider Build (xxxxx)
May 2019 Update (18362) Yes
October 2018 Update (17763)
April 2018 Update (17134)
Fall Creators Update (16299)
Creators Update (15063)
Device form factor Saw the problem?
Desktop Yes>
Mobile
Xbox
Surface Hub
IoT

Additional context This issue was discovered as part of investigation into https://github.com/microsoft/WindowsTemplateStudio/issues/3407

jevansaks commented 4 years ago

It's intentional that the close button isn't reachable with keyboard (same as Edge/Chrome).

@mrlacey Does Ctrl+F4 not work? @Stmoy what is the keyboard accessible expectation?

mrlacey commented 4 years ago

Does Ctrl+F4 not work?

Does Ctrl+F4 does nothing.

stmoy commented 4 years ago

Ctrl+F4 should raise the TabCloseRequested event automatically. This sounds like a bug in TabView.

We also discussed the TabView raising TabCloseRequested on Ctrl+W, but decided that the app can handle that case if appropriate.

EDIT: Ctrl+F4 does the correct thing in the keyboarding sample in the Xaml Controls Gallery. @mrlacey - where is focus when you hit Ctrl+F4? Perhaps something else is eating that keyboard input?

mrlacey commented 4 years ago

I take it back. Ctrl+F4 does raise the right event. (My sample app had been modified so I didn't see it when I initially checked.)

The docs also say "mousewheel" should trigger the event too, but I don't see that.

Is there also a way to close a tab if using an Xbox game controller connected to a PC?

stmoy commented 4 years ago

The docs also say "mousewheel" should trigger the event too, but I don't see that.

Interesting. This should also be automatically handled by the TabView control. It appears to work this way in the Gallery. Can you double check this one as well? By "mousewheel" we mean "middle click" (which is usually done by the mousewheel).

Is there also a way to close a tab if using an Xbox game controller connected to a PC?

Good catch. The expectation is that the app places a context menu/MenuFlyout on each tab with a "close tab" option.

Thinking out loud: we explicitly don't want to make the x-to-close button a TAB stop. However, maybe it should be gamepad-arrow focusable. Thoughts?

jevansaks commented 4 years ago

Thinking out loud: we explicitly don't want to make the x-to-close button a TAB stop. However, maybe it should be gamepad-arrow focusable. Thoughts?

Is that even possible?

I think just offering a default context menu seems best. That makes it more obvious for keyboard and gamepad users.

mrlacey commented 4 years ago

By "mousewheel" we mean "middle click" (which is usually done by the mousewheel).

Yes, I was middle-clicking with the mousewheel but it did not realize the cursor has to be over the tab and this doesn't work if the cursor is over the tab's content.

I think just offering a default context menu seems best. That makes it more obvious for keyboard and gamepad users.

A default content item would be a good solution. Also having the Ctrl+F4 shortcut documented somewhere a user might possibly find it would also be good. I expect to see it as a tool-tip on on the close button.

stmoy commented 4 years ago

We're investigating what else we can/should do for the next rev of TabView. I've added this as an item in that list tracked in #1332.

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 5 days.