AvaloniaUI / Avalonia

Develop Desktop, Embedded, Mobile and WebAssembly apps with C# and XAML. The most popular .NET UI client technology
https://avaloniaui.net
MIT License
25.9k stars 2.24k forks source link

Deselecting a textbox when outside of immediate view in scrollviewer causes issues #3829

Open eggroll-bot opened 4 years ago

eggroll-bot commented 4 years ago

When a textbox with focus is outside of the immediate view, in a ScrollViewer, having the textbox lose focus (which can be done by selecting another object) makes it so that the ScrollViewer will jump back up to the textbox and deselect it. Is this intended behavior? And if so, is there a way to disable such functionality?

aguahombre commented 4 years ago

Avalonia 0.9.9 I have also seen this where a Button click is ignored if a TextBox has focus and is scrolled off screen and the button is inside the same ScrollViewer. Instead the ScrollViewer scrolls the TextBox back into view. Clicking the button again then fires the command correctly.

VladiStep commented 11 months ago

Avalonia 11.0.5.

I have this AXAML code:

<Border Grid.Row="2" Grid.ColumnSpan="2" Classes="loadingStatusBorder">
    <ScrollViewer Name="LoadingStatusScroll">
        <SelectableTextBlock Classes="normal" Name="LoadingStatusText"/>
    </ScrollViewer>
</Border>

When I try to focus the text and then make the scroll viewer get the focus, this line of code brings the text into view, which somehow causes the scroll viewer to scroll to the start (even if the text is visible).

xLEGiON commented 7 months ago

Avalonia 11.0.5.

I have this AXAML code:

<Border Grid.Row="2" Grid.ColumnSpan="2" Classes="loadingStatusBorder">
  <ScrollViewer Name="LoadingStatusScroll">
      <SelectableTextBlock Classes="normal" Name="LoadingStatusText"/>
  </ScrollViewer>
</Border>

When I try to focus the text and then make the scroll viewer get the focus, this line of code brings the text into view, which somehow causes the scroll viewer to scroll to the start (even if the text is visible).

I had this problem too, but I found that you can set the BringIntoViewOnFocusChange property of the ScrollViewer to false to prevent it from doing this.

It's possible that the issues reported by the other users above could be resolved by doing this too, but I haven't tested.