dotnet / wpf

WPF is a .NET Core UI framework for building Windows desktop applications.
MIT License
6.93k stars 1.15k forks source link

Screen-reader reads lines twice in a TextBox / TextBlock / RichTextBox #7190

Open origine999 opened 1 year ago

origine999 commented 1 year ago
protected override void OnInitialized(EventArgs e)
        {
            base.OnInitialized(e);
            var tb = new TextBox();
            tb.AcceptsReturn = true;
            var layout = new StackPanel();
            layout.Children.Add(tb);
            this.Content = layout;
            tb.Text = "Hello, this is a test\r\n\r\nThis is a second line of text, you will notice that if you move focus to the line above this line, you will also hear this line, this makes Narrator read it twice.\r\n\r\nAgain, you will hear this third line twice";
            tb.Focus();
        }
  1. Start debugging
  2. Put your text cursor at the very beginning of the textbox (Ctrl+Home).
  3. Start Narrator (Ctrl+Win+Enter, or from Start menu). You can also use NVDA.
  4. With focus in the textbox, press the down arrow
  5. Notice that when you are on line 2, which is blank, Narrator / NVDA will read the third line of text.
  6. Press the down arrow again
  7. This time Narrator and NVDA read line 3 correctly, reading line 3 for the second time.
  8. Keep pressing down and up arrow to notice how Narrator / NVDA will read the line of text below a blank line instead of reading "blank".

    Additional information I might be wrong in this section, I just thought since I did more investigation I would put it here in case it's useful.

This seems like a UIA provider bug.

When debugging WPF, I noticed that in TextRangeAdapter.cs --> line 522: private void ExpandToEnclosingUnit(TextUnit unit, bool expandStart, bool expandEnd)

Other notes:

codeofdusk commented 1 year ago

A good reference implementation for expected UIA text range behaviour is MS Word (winword.exe).

cary-rowen commented 5 months ago

Any progress on this? This problem has plagued screen reader users for more than a decade.

Adriani90 commented 2 weeks ago

cc: @siagupta0202, @anjali-wpf, @Arpitmathur, @dipeshmsft, @Himgoyalmicro, @harshit7962 could someone please look into this? It impacts alot users in multiple scenarios, especially when using braille displays and the same line is shown on the display although the caret moved to a different line. The same happens with speech from the screen reader. It would be really nice to see some improvements to accessibility of WPF in this regard.