Microsoft-ui-xaml: Bug: The selected text highlight often disappears on right-click.

Created on 1 Jan 2020  路  5Comments  路  Source: microsoft/microsoft-ui-xaml

Describe the bug

The selected text highlight disappears most of the time after right clicking it. This applies to:

  • TextBox
  • TextBlock
  • RichTextBlock
  • RichEditBox
  • PasswordBox
  • AutoSuggestBox

Steps to reproduce the bug

  1. Open the XAML Controls Gallery > Text > any sample
  2. Select some text (enter it first if necessary)
  3. Right-click said text to bring up the context menu

NOTE: It doesn't always happen on the first right-click, but simply right-click again on the text without closing the context menu and it will typically disappear then.

Expected behavior

The selected text highlight should remain visible until the selected text is no longer selected.

Contrast this behavior to right-clicking text in OneNote; you can right-click selected text there as many times as you like and whatever was selected will keep its highlight the whole time.

Version Info
XAML Controls Gallery v.1.2.11.0

NuGet package version:


| Windows 10 version | Saw the problem? |
| :--------------------------------- | :-------------------- |
| Insider Build (xxxxx) | |
| May 2019 Update (18362) | Yes |
| October 2018 Update (17763) | |
| April 2018 Update (17134) | |
| Fall Creators Update (16299) | |
| Creators Update (15063) | |


| Device form factor | Saw the problem? |
| :-------------------- | :------------------- |
| Desktop | Yes/No? |
| Mobile | |
| Xbox | |
| Surface Hub | |
| IoT | |

area-TextBlocks area-TextBox bug team-Framework

All 5 comments

I see this on controls gallery as well.

I had this issue in one of my apps and I worked around it by setting SelectionHighlightColorWhenNotFocused, I hope this helps 馃檪

<TextBox>
  <TextBox.SelectionHighlightColorWhenNotFocused>
    <SolidColorBrush Color="{StaticResource SystemAccentColor}"/>
  </TextBox.SelectionHighlightColorWhenNotFocused>
</TextBox>

@yaichenbaum

Using SelectionHighlightColorWhenNotFocused is just a workaround rather than a fix, as now the expected behavior that the selection color change when the app or TextBox loses focus is gone.

Popping a context menu for selected text shouldn't cause the text to lose focus. Or if it has to lose focus, then there needs to be logic or a new property to handle this scenario (although that property would/should be equal to SelectionHighlightColor by default).

I can also repro. It does just seem to be the visual state; selection state restores when the menu closes. Given the workaround above it does seem like focus is getting lost/restored.
@ddalp (Text) and @Austin-Lamb (Focus): Does this at all sound familiar (TextBox losing focus while context menu is up)?

@chrisglein It is a bug. @marlenecota had to fake the focus still on Text Control while floatie is shown. This looks like another case we did not handle the fake focus well.

Was this page helpful?
0 / 5 - 0 ratings