Skip to content

Conversation

LeafShi1
Copy link
Member

@LeafShi1 LeafShi1 commented Oct 15, 2025

Fixes #10408

Proposed changes

  • TabControlAccessibleObject
    • Removed logic that exposed TabPage Panel as a direct child of TabControl.
    • FragmentNavigate now only returns TabItem objects for FirstChild and LastChild.
  • TabAccessibleObject
    • Added logic to expose TabPage Panel as FirstChild when the tab is selected.
    • Maintains sibling navigation for other tab items.
  • TabPageAccessibleObject
    • Updated Parent and FragmentRoot to point to the corresponding TabItem instead of TabControl.
    • Removed any logic that previously treated the panel as a sibling of tab items.

Customer Impact

  • Improved Accessibility Compliance: The new structure aligns with UIA best practices, making the hierarchy intuitive for assistive technologies.
  • Better Screen Reader Experience: Users will now hear the correct relationship between a tab item and its content, improving usability for visually impaired users.
  • Reduced Automation Errors: Automated tests and AI tools will no longer encounter ambiguous sibling relationships between tab items and panels.
  • Consistent Tree Representation: Tools like Inspect and UIA Verify will display a predictable and logical structure, reducing developer confusion and debugging time.

Regression?

  • Yes

Risk

  • Minimal

Screenshots

Before

In the .net project, TreeWalker only obtain the panel. Example project WinFormsApp71.zip

image

After

In the .net project, TreeWalker can obtain the tabitem
image

Test methodology

  • Manually
  • Accessibility tools

Test environment(s)

  • .net 10.0.0-rc.1.25468.102
Microsoft Reviewers: Open in CodeFlow

@LeafShi1 LeafShi1 requested a review from a team as a code owner October 15, 2025 10:23
@LeafShi1 LeafShi1 requested review from Copilot and removed request for a team October 15, 2025 10:23
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR restructures the accessibility hierarchy for TabControl to place TabPanel as a child of TabItem instead of a sibling, improving compliance with UIA best practices and enhancing screen reader experience.

Key Changes

  • Moved TabPage Panel from being a direct child of TabControl to being a FirstChild of the selected TabItem
  • Updated navigation logic to properly handle parent-child relationships between TabItems and their panels
  • Removed outdated sibling navigation logic that treated panels as peers of tab items

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
TabPage.TabPageAccessibleObject.cs Updated FragmentRoot and FragmentNavigate to establish TabItem as parent, removed sibling navigation logic
TabPage.TabAccessibleObject.cs Added FirstChild navigation to expose panel when tab is selected, improved sibling navigation between tabs
TabControl.TabControlAccessibleObject.cs Modified FirstChild navigation to return first TabItem instead of selected tab's panel

Comment on lines +14 to +19
private readonly TabPage _owningTabPage;

public TabPageAccessibleObject(TabPage owningTabPage) : base(owningTabPage)
{
_owningTabPage = owningTabPage;
}
Copy link

Copilot AI Oct 15, 2025

Choose a reason for hiding this comment

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

The private field _owningTabPage duplicates the base class's owner tracking. Consider using the existing TryGetOwnerAs<TabPage>() method or accessing the owner through the base class instead of storing a separate reference.

Copilot uses AI. Check for mistakes.

return null;
}

int index = OwningTabControl.TabPages.IndexOf(_owningTabPage);
Copy link

Copilot AI Oct 15, 2025

Choose a reason for hiding this comment

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

The IndexOf operation is called on every navigation request, which could be inefficient for large tab collections. Consider caching the index or using a more efficient lookup mechanism if navigation frequency is high.

Copilot uses AI. Check for mistakes.

@LeafShi1 LeafShi1 marked this pull request as draft October 16, 2025 10:07
@dotnet-policy-service dotnet-policy-service bot added the draft draft PR label Oct 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WinForms TabControl does not expose TabItem controls to UIAutomation

1 participant