Avalonia icon indicating copy to clipboard operation
Avalonia copied to clipboard

SelectableTextBlock with Inlines render issue

Open love-linger opened this issue 6 months ago • 0 comments

Describe the bug

SelectableTextBlock with inlines renders no content after closing context menu of another control by click this SelectableTextBlock.

To Reproduce

  1. Create an Avalonia .NET App (AvaloinaUI) project
  2. Replace the content in MainWindow.axaml with the code shown below
<Window xmlns="https://github.com/avaloniaui"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
        Width="400" Height="200"
        x:Class="SelectableTextBlockDemo.MainWindow"
        Title="SelectableTextBlockDemo">
  <StackPanel Orientation="Vertical">
    <TextBlock Text="SelectableTextBlock Demo" Margin="0,12" HorizontalAlignment="Center"/>
    
    <Border Background="Green" Height="24">
      <Border.ContextMenu>
        <ContextMenu>
          <MenuItem Header="Just a menu item 1"/>
          <MenuItem Header="Just a menu item 2"/>
        </ContextMenu>
      </Border.ContextMenu>
      
      <TextBlock Text="Right Click Here to Open Context Menu" HorizontalAlignment="Center" VerticalAlignment="Center"/>
    </Border>
    
    <SelectableTextBlock Background="Transparent" FontSize="16" Margin="0,8,0,0" HorizontalAlignment="Center">
      <Run>This is a</Run>
      <Run Foreground="Red">SelectableTextBlock</Run>
      <Run>with inline elements</Run>
    </SelectableTextBlock>

    <SelectableTextBlock Background="Transparent" FontSize="16" Margin="0,8,0,0" HorizontalAlignment="Center" Text="This is a SelectableTextBlock without inlines"/>
  </StackPanel>
</Window>
  1. As shown in the video, run the project

Expected behavior

After the context menu closed by clicking above the first SelectableTextBlock, the first SelectableTextBlock should redraw correctly.

Avalonia version

11.1.3

OS

Windows, macOS, Linux

Additional context

This video shows how to reproduce this issue

https://github.com/user-attachments/assets/365b6d2b-f486-4bb9-a4b1-78ddd978a874

love-linger avatar Aug 27 '24 04:08 love-linger