Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Narrator repeats one extra time at ToggleSwitch when OnContent or OffContent is set in UWP #9326

Closed
riqmariz opened this issue Feb 9, 2024 · 1 comment
Labels
appModel-UWP Exclusive to WinUI 2 UWP apps area-ToggleSwitch bug Something isn't working team-Controls Issue for the Controls team

Comments

@riqmariz
Copy link

riqmariz commented Feb 9, 2024

Describe the bug

I am currently implementing a custom ToggleSwitch in UWP based on Microsoft's template. However, I've encountered a peculiar bug related to the narrator behavior, which seems to be resolved in WinUI 3 but persists in UWP (WinUI 2). I'm seeking assistance to address this issue.

If the OnContent or OffContent is set at the toggle switch it will cause the narrator to repeat itself one time. If you don't use this properties, it reads perfectly, without repeating itself.

<StackPanel Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center">
        <ToggleSwitch x:Name="A" />
        <Grid>
            <ToggleSwitch
                x:Name="B"
                OffContent="Disable"
                OnContent="Enable"
               />
        </Grid>
    </StackPanel>

In the provided example code, the first ToggleSwitch with the x:Name 'A' behaves correctly. However, when the OnContent and OffContent properties are set, as in the second ToggleSwitch with the x:Name 'B,' the narrator repeats itself one extra time. The expected behavior is to read 'Enable, Toggle Switch, ON' or 'Disable, Toggle Switch, OFF,' but it reads something like 'Enable, Toggle Switch, ON, Enable, Toggle Switch, ON." or the analogue

How can I overcome this issue and prevent the narrator from repeating itself when using the OnContent and OffContent properties in a UWP ToggleSwitch? Any insights or workarounds would be greatly appreciated.

Steps to reproduce the bug

  1. Go to your UWP project with the code snippet described;
  2. Select Toggle Switch component that has OnContent and OffContent;
  3. Have narrator activated;
  4. Navigate through the keyboard to component (Or Click);
  5. Press space key to change value;
    [BUG] - Narrator read twice: On/Off Content+ component+ state

Expected behavior

Narrator read once: On/Off Content+ component+ state

Screenshots

image

Toggle Switch Narrator Test.zip

NuGet package version

WinUI 2 - Microsoft.UI.Xaml 2.8.2

Windows version

Windows 10: Build 19041 (version 2004)

Additional context

I've already posted something similar at: https://learn.microsoft.com/en-us/answers/questions/1526247/how-to-make-narrator-do-not-repeat-the-sentence-wh

I still had no success to work this around.

I've attempted to use AutomationProperties.SetName(component, name) but it does not work in every scenario for me.

Also, tried to implement a AutomationPeer but the ToggleSwitch is a sealed class. Therefore, I'm using composition. As a result, I couldn't use ToggleSwitchAutomationPeer even when passing the component as a parameter. I attempted to use FrameworkElementAutomationPeer instead and I've implemented it similarly to ToggleSwitchAutomationPeer (like described on the section remarks on this link ToggleSwitchAutomationPeer) but it always seems to result in a wrong case, not always on the narrator, but sometimes it don't focus right with the proper narrator border, because the control itself do not inherits from toggle switch, it contains one toggle switch, that messes everything up.

@riqmariz riqmariz added the bug Something isn't working label Feb 9, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the needs-triage Issue needs to be triaged by the area owners label Feb 9, 2024
@codendone codendone added team-Controls Issue for the Controls team area-ToggleSwitch appModel-UWP Exclusive to WinUI 2 UWP apps and removed needs-triage Issue needs to be triaged by the area owners labels Feb 22, 2024
@ranjeshj
Copy link
Contributor

ranjeshj commented Mar 5, 2024

@riqmariz thanks for reporting. We are currently not fixing non-critical bugs in winui2. See - https://github.com/microsoft/microsoft-ui-xaml/blob/main/docs/contribution_handling.md#winui-2

@ranjeshj ranjeshj closed this as not planned Won't fix, can't repro, duplicate, stale Mar 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
appModel-UWP Exclusive to WinUI 2 UWP apps area-ToggleSwitch bug Something isn't working team-Controls Issue for the Controls team
Projects
None yet
Development

No branches or pull requests

3 participants