Skip to content

Add focus rectangle to PrintPreviewControl#9477

Merged
dreddy-work merged 9 commits intodotnet:mainfrom
v-elnovikova:Issue_9275_Adding_Focus_Rectangle_To_PrintPreviewControl
Jul 26, 2023
Merged

Add focus rectangle to PrintPreviewControl#9477
dreddy-work merged 9 commits intodotnet:mainfrom
v-elnovikova:Issue_9275_Adding_Focus_Rectangle_To_PrintPreviewControl

Conversation

@v-elnovikova
Copy link
Copy Markdown
Contributor

@v-elnovikova v-elnovikova commented Jul 12, 2023

Fixes #9275

Proposed changes

  • Replace native scrolling with VScrollBar and HScrollBar controls. Native scrolling did not allow drawing focus rectangle that would include scrollbars.
  • Draw focus rectangle when PrintPreviewControl has focus.
  • Revert hiding PrintPreviewControl.TabStop property from Designer (see PR Hiding TabStop property of PrintPreviewControl from Designer and setting the default value as false. #7529). Default value is left false to avoid breaking existing code.
  • Modify PrintPreviewControlAccessibleObject class to include new scrollbars.
  • Clean up the code.

Customer Impact

  • User can switch focus to PrintPreviewControl with Tab key.
  • PrintPreviewControl shows its focus state.

Regression?

  • No

Risk

  • PrintPreviewControl AccessibilityConject now lacks Scroll pattern support. It needs to be added in separate PR.

Screenshots

Before

Focus rectangle is not visible:

before.mp4

After

Focus is visible:

after.mp4

This is how Focus rectangle looks in High Contrast themes:
high_contrast

Test methodology

  • Manual

Test environment(s)

  • .NET 8.0.100-preview.4.23260.5
Microsoft Reviewers: Open in CodeFlow

@v-elnovikova v-elnovikova requested a review from a team as a code owner July 12, 2023 14:35
@ghost ghost assigned v-elnovikova Jul 12, 2023
@v-elnovikova v-elnovikova added the waiting-review This item is waiting on review by one or more members of team label Jul 12, 2023
@Tanya-Solyanik
Copy link
Copy Markdown
Contributor

Test failure is in the PrintPreview control -
System.NullReferenceException : Object reference not set to an instance of an object.

Stack trace
at System.Windows.Forms.PrintPreviewControl.Dispose(Boolean disposing) in //src/System.Windows.Forms/src/System/Windows/Forms/Printing/PrintPreviewControl.cs:line 85
at System.ComponentModel.Component.Dispose()
at System.Windows.Forms.Tests.Control_ControlAccessibleObjectTests.ControlAccessibleObject_FragmentNavigate_ParentIsToolStrip_IfControlIsUsedAsToolStripItem(Type type) in /
/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/Control.ControlAccessibleObjectTests.cs:line 1501
at InvokeStub_Control_ControlAccessibleObjectTests.ControlAccessibleObject_FragmentNavigate_ParentIsToolStrip_IfControlIsUsedAsToolStripItem(Object, Object, IntPtr*)
at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)

Copy link
Copy Markdown
Contributor

@Tanya-Solyanik Tanya-Solyanik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please send this to testing and review the change history for the change that hid the TabStop to see if we had updated the docs . If we did, then please prepare a docs issue to roll this back.

@Tanya-Solyanik
Copy link
Copy Markdown
Contributor

Would it make sense to add new unit tests for the new accessible object?

@Tanya-Solyanik Tanya-Solyanik added the waiting-author-feedback The team requires more information from the author label Jul 12, 2023
@v-elnovikova v-elnovikova force-pushed the Issue_9275_Adding_Focus_Rectangle_To_PrintPreviewControl branch from 8c78a55 to 5fd1590 Compare July 14, 2023 07:59
@ghost ghost removed the waiting-author-feedback The team requires more information from the author label Jul 14, 2023
@dreddy-work dreddy-work added waiting-author-feedback The team requires more information from the author and removed waiting-review This item is waiting on review by one or more members of team labels Jul 14, 2023
@Tanya-Solyanik
Copy link
Copy Markdown
Contributor

Tests are still failing -
System.NullReferenceException : Object reference not set to an instance of an object.

Stack trace
at System.Windows.Forms.PrintPreviewControl.Dispose(Boolean disposing) in //src/System.Windows.Forms/src/System/Windows/Forms/Printing/PrintPreviewControl.cs:line 85
at System.ComponentModel.Component.Dispose()
at System.Windows.Forms.Tests.Control_ControlAccessibleObjectTests.ControlAccessibleObject_FragmentNavigate_ParentIsToolStrip_IfControlIsUsedAsToolStripItem(Type type) in /
/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/Control.ControlAccessibleObjectTests.cs:line 1486
at InvokeStub_Control_ControlAccessibleObjectTests.ControlAccessibleObject_FragmentNavigate_ParentIsToolStrip_IfControlIsUsedAsToolStripItem(Object, Object, IntPtr*)
at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)

Copy link
Copy Markdown
Contributor

@dmitrii-drobotov dmitrii-drobotov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

@ghost ghost removed the waiting-author-feedback The team requires more information from the author label Jul 18, 2023
- replace native scrollbars with HScrollBar and VScrollBar controls;
- draw focus rectangle
- modify UIA tree to include new scrollbars.
- renamed fields to start with underscore;
- reordered class members to improve readability;
- refactored size calculation methods to avoid unnecessary casts.
@v-elnovikova v-elnovikova force-pushed the Issue_9275_Adding_Focus_Rectangle_To_PrintPreviewControl branch from 823aafd to 1328a94 Compare July 18, 2023 18:16
- moved PrintPreviewControlAccessibleObject file to Printing folder;
- reverted adding SR resource strings;
- added FragmentNavigate method for PrintPreviewControlAccessibleObject;
- added custom AccessibleObject classes for scrollbars, to maintain UIA tree integrity;
- added unit tests.
@v-elnovikova v-elnovikova force-pushed the Issue_9275_Adding_Focus_Rectangle_To_PrintPreviewControl branch from 1328a94 to c5d84eb Compare July 19, 2023 09:04
@v-elnovikova v-elnovikova added the waiting-review This item is waiting on review by one or more members of team label Jul 19, 2023
@Tanya-Solyanik Tanya-Solyanik removed the waiting-review This item is waiting on review by one or more members of team label Jul 19, 2023
@Tanya-Solyanik Tanya-Solyanik added the waiting-for-testing The PR is awaiting manual testing by the primary team; no action is yet required from the author(s) label Jul 19, 2023
Tanya-Solyanik
Tanya-Solyanik previously approved these changes Jul 19, 2023
@Tanya-Solyanik Tanya-Solyanik added this to the .NET 8.0 milestone Jul 19, 2023
@Tanya-Solyanik
Copy link
Copy Markdown
Contributor

Tanya-Solyanik commented Jul 19, 2023

This fixes bug discovered in an accessibility test pass, it should be shipped in NET8 per the SLA, thus moving it into the NET8 milestone. Risk is in incomplete implementation of the accessibility features, and should not affect the runtime functionality of the control

@v-elnovikova v-elnovikova force-pushed the Issue_9275_Adding_Focus_Rectangle_To_PrintPreviewControl branch from ed8eeaa to a7550e0 Compare July 21, 2023 14:43
@v-elnovikova v-elnovikova added waiting-review This item is waiting on review by one or more members of team and removed waiting-for-testing The PR is awaiting manual testing by the primary team; no action is yet required from the author(s) waiting-review This item is waiting on review by one or more members of team labels Jul 26, 2023
Copy link
Copy Markdown
Contributor

@Tanya-Solyanik Tanya-Solyanik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@Tanya-Solyanik Tanya-Solyanik added ready-to-merge PRs that are ready to merge but worth notifying the internal team. and removed waiting-review This item is waiting on review by one or more members of team labels Jul 26, 2023
@dreddy-work dreddy-work merged commit 6678f53 into dotnet:main Jul 26, 2023
@ghost ghost modified the milestones: .NET 8.0, 8.0 RC1 Jul 26, 2023
@ghost ghost removed the ready-to-merge PRs that are ready to merge but worth notifying the internal team. label Jul 26, 2023
@v-elnovikova v-elnovikova deleted the Issue_9275_Adding_Focus_Rectangle_To_PrintPreviewControl branch July 27, 2023 09:03
@ghost ghost locked as resolved and limited conversation to collaborators Aug 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

4 participants