* Add failing test for #7536
Reproduces the "Cannot change source while update is in progress" crash that
occurs when a SelectingItemsControl's ItemsSource is changed from within its own
SelectionChanged handler while the selection is being lost. When selection is
lost, CommitOperation bumps the operation UpdateCount before raising
LostSelection but never decrements it, so SelectionChanged is raised with
UpdateCount > 0 and SetSource throws.
Claude-Session: https://claude.ai/code/session_01FXP1ejZ9VhUwecY9QCRKVb
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* Fix#7536: crash when changing source during SelectionChanged
When the selection was lost, SelectionModel.CommitOperation incremented the
operation's UpdateCount before raising LostSelection but never decremented it.
As a result the rest of the commit - including the SelectionChanged event - ran
with UpdateCount > 0, so a handler that changed the control's source (as
StructuredLogViewer's UpdateBreadcrumb does) hit the "Cannot change source while
update is in progress." guard in SetSource and threw.
Decrement UpdateCount again once the LostSelection handler has returned so that
the batching only covers the handler itself and the SelectionChanged event is
free to change the source.
Claude-Session: https://claude.ai/code/session_01FXP1ejZ9VhUwecY9QCRKVb
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* Add test for changing selection from SelectionChanged when AlwaysSelected reselects
Covers the interaction between the #7536 fix and AlwaysSelected: clearing the
selection makes AlwaysSelected reselect the first item via LostSelection (which
must still fold into the current operation), and a SelectionChanged handler that
then changes the selection must be honoured rather than swallowed by the batch
update wrapping the LostSelection handler. Fails before the fix (selection stays
on the reselected item), passes after.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FXP1ejZ9VhUwecY9QCRKVb
* Assert that `SelectionChanged` was called.
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
* Add BringIntoView pass to the LayoutManager
* Make ProcessBringIntoViewRequests part of the standard layout pass
* Clarify why TryScrollIntoViewNow's result is ignored
---------
Co-authored-by: grokys <grokys@users.noreply.github.com>
* Add failing test for #14718
* Fix for AutoScrollToSelectedItemIfNecessary
* fix failing CI build and move test to the right location
* add failing test for TabItem selection of invisble tab
* introduce a helper method to figure out which item to select
when nothing was selected beforehand and AlwaysSelected is true
* ensure selection works for invisible tabcontrol
* simplify conditions
* propose: Remove redundant logic from ColorView
The TabItem now handles the correct selection of only visible items
* fix test: Need to set SelectedIndex after adding items
* re-add unused method and make it obsolete
Otherwise API-diff will fail.
* Address review
* Update tests/Avalonia.Controls.UnitTests/TabControlTests.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Update tests/Avalonia.Controls.UnitTests/TabControlTests.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Adress copilot review
* fix duplicate braces
* address review
* fix for failing tests on CarouselPage and TabbedPage
* address feedback
- adding more tests to avoid regressions
* Fix failing test: add UnitTestApplication.Start() to dedicated thread test
Agent-Logs-Url: https://github.com/timunie/Avalonia/sessions/fe2f1190-6d20-4982-8a03-1ae9b52ee701
Co-authored-by: timunie <47110241+timunie@users.noreply.github.com>
* Refactor SelectingItemsControl auto-scroll duplicate logic
Agent-Logs-Url: https://github.com/timunie/Avalonia/sessions/8895cb60-ef41-473c-972b-bad2483a5a77
Co-authored-by: timunie <47110241+timunie@users.noreply.github.com>
* Add new failing tests for AlwaysSelected mode
* Fix AlwaysSelected scenarios
---------
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Julien Lebosquain <julien@lebosquain.net>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Rather than using the `ISelectable` interface to communicate container selection from the `SelectingItemsControl` to the container, use the `SelectingItemsControl.IsSelected` attached property, setting it with `SetCurrentValue` so that bindings defined in a style or item container theme can override the selection. Required an extra virtual `ContainerForItemPreparedOverride` method on `ItemsControl`.
A lot still broken, in particular virtualization is completely removed.`ItemsPresenter` now no longer has an `Items` or `ItemTemplate` property; it detects when it's hosted in an `ItemsControl`. `IItemsPresenter` interface removed.
After the selected item is removed from a `ListBox` with `AlwaysSelected == true`, the container for the newly selected item does not get `:selected` applied.