dotnet / winforms

Windows Forms is a .NET UI framework for building Windows desktop applications.
MIT License
4.4k stars 976 forks source link

A11y_.NET Core_WinForms_PrintingTesting_PrintingTesting_Keyboard: Keyboard focus is not going to the "View your page" "Pane". #9275

Closed HindujaArugula closed 1 year ago

HindujaArugula commented 1 year ago

.NET version

.NET-SDK-8.0.100-preview.4.23260.5

Did it work in .NET Framework?

No

Did it work in any of the earlier releases of .NET Core or .NET 5+?

No response

Issue description

GitHubTags:

A11yMAS;#A11yTCS;#BM_.NET Core[Winforms]-Win32-May2023;#.NET Core;#A11ySev2;#WCAG2.1.1;#DesktopApp;#Win11;#NonBenchmark;#Keyboard;

Actual:

Keyboard focus is not going to the "View your page" "Pane".

Expected:

Keyboard focus should go to the "View your page" "Pane".

User Impact:

Keyboard only users will face difficulties if the keyboard focus does not to the "View your page" pane.

Steps to reproduce

  1. Install and Open "Winforms" App.
  2. "Main Form" screen would appear.
  3. TAB to "Printing_Controls:Testing the controls under the Printings Tab" and press ENTER key.
  4. "Printing Testing" screen appears.
  5. Now observe that Keyboard focus is not going to the "View your page" "Pane".

Attachment:

Keyboard1

merriemcgaw commented 1 year ago

@dmitrii-drobotov @Tanya-Solyanik are we able to get the pane selected? This seems awfully familiar to me, like we've already addressed it at some point.

dmitrii-drobotov commented 1 year ago

Yeah, I found these issues: https://github.com/dotnet/winforms/issues/3660 and https://github.com/dotnet/winforms/issues/3678. From what I can tell, it's intended that this pane is not selectable.

Tanya-Solyanik commented 1 year ago

@merriemcgaw @dmitrii-drobotov Print preview control had never displayed focus and there is nothing selectable inside the control. The only thing customer might want to do is to scroll up and down to see more pages. Are there any keyboard shortcuts that control scroll bars? Scroll Lock key does not work for me in winforms apps.

dmitrii-drobotov commented 1 year ago

Are there any keyboard shortcuts that control scroll bars? Scroll Lock key does not work for me in winforms apps.

Print preview can be scrolled by Ctrl+Arrows, but it needs to have TabStop = true. A gif showing that PrintPreviewControl content can be scrolled by Ctrl+Arrows

Tanya-Solyanik commented 1 year ago

Print preview can be scrolled by Ctrl+Arrows, but it needs to have TabStop = true.

Yeah, I think it was a mistake to remove TabStop there. @merriemcgaw looks like we should add the focus border to print preview

merriemcgaw commented 1 year ago

OK, let's get that in.

v-elnovikova commented 1 year ago

The content of PrintPreviewControl is drawn in overriden OnPaint method. So, the easiest way to add a focus rectangle would be to draw it inside OnPaint. But OnPaint can only draw client area, i.e. it does not include scroll bars. Focus rectangle around the client area would look like this:

PrintPreviewControl - inner focus rectangle

Focus rectangle is drawn inside of PrintPreview, around the gray area. Here is an animation of switching focus:

https://github.com/dotnet/winforms/assets/113603457/4b88d5a3-d330-4285-9a76-7cb0572402d1

Scroll bars in PrintPreview are native, added using WS_HSCROLL and WS_VSCROLL window styles. I see two ways to make focus rectangle include scrollbars:

Reworking control to use .NET scrollbars would change accessibility tree structure, adding ScrollBarAccessibleObject-s to the tree.

Handling WM_NCPAINT may not be sufficient. For example, when user moves mouse cursor over the scrollbar, the focus rectangle is overdrawn by windows, but WM_NCPAINT message is not sent. Some workaround is needed here, maybe handling MouseMove event and calling RedrawWindow to refresh focus rectangle.

Ashley-Li commented 1 year ago

Verified this on .NET 8.0 latest build: 8.0.100-rc.1.23402.12, it was fixed. Now keyboard focus is going to the "View your page" "Pane".

https://github.com/dotnet/winforms/assets/56664234/68733d36-4187-4b8f-9b77-01757e7ebc42

HindujaArugula commented 1 year ago

@merriemcgaw @Tanya-Solyanik Could you please provide the latest environment to verify the issue. PendingEnvironment; Regressed:08-16-23;

Tanya-Solyanik commented 1 year ago

@Ashley-Li , @Olina-Zhang Could you please help with the current test environment?

Olina-Zhang commented 1 year ago

Here is the testing app: \\mlangfs1\public\Winforms\CoreTest\AccessibilityTestingApp\CoreApplication\CoreSDK8.0_Test_app\Accessibility_Core_8.0_AppExe.zip and required .Net 8.0 SDK: \\mlangfs1\public\Winforms\CoreTest\AccessibilityTestingApp\CoreApplication\CoreSDK8.0_Test_app\dotnet-sdk-8.0.100-rc.2.23417.14-win-x64.exe

Amy-Li03 commented 1 year ago

Verified this on .NET 8.0 RC1 test pass build: 8.0.100-rc.1.23421.2, it was fixed, test result is same as above video.

HindujaArugula commented 1 year ago

Verified the issue in latest testing app i.e., \mlangfs1\public\Winforms\CoreTest\AccessibilityTestingApp\CoreApplication\CoreSDK8.0_Test_app\Accessibility_Core_8.0_AppExe.zip. Issue is fixed and does not repro. Hence closing the bug. Please find closing attachment.

Closed; #Regressed:08-24-23

Keyboard focus_Fixed