@@ -536,30 +536,50 @@ await ui.RunOnUIAsync(() =>
536536 Assert . Equal ( 5 , panels . Tabs . Count ) ;
537537 } ) ;
538538 }
539+ // TabView brings its selected tab into view after selection and presenter resizes, so a
540+ // ChangeView to the start races a late bring-into-view of the last tab. Select the first tab.
539541 await ui . RunOnUIAsync ( ( ) =>
540542 {
541543 var view = FindControl < TabView > ( surface ! , "ConversationPanelTabs" ) ;
542- var scroll = Assert . Single ( FindDescendants < ScrollViewer > ( view ) ,
543- candidate => candidate . ScrollableWidth > 0 ) ;
544- scroll . ChangeView ( 0 , null , null , disableAnimation : true ) ;
544+ view . SelectedItem = view . TabItems [ 0 ] ;
545+ Assert . Equal ( "files" , panels . Selected ) ;
546+ } ) ;
547+ ScrollViewer Strip ( ) => Assert . Single (
548+ FindDescendants < ScrollViewer > ( FindControl < TabView > ( surface ! , "ConversationPanelTabs" ) ) ,
549+ scroll => scroll . ScrollableWidth > 0 ) ;
550+ // The selection brings the first tab back into view before the arrow is clicked.
551+ await ui . RunOnUIAsync ( ( ) => WaitForRenderedConditionAsync ( ( ) =>
552+ {
553+ var view = FindControl < TabView > ( surface ! , "ConversationPanelTabs" ) ;
554+ var viewport = Assert . Single ( FindDescendants < ScrollContentPresenter > ( view ) ) ;
555+ return FindDescendants < RepeatButton > ( view ) . Any ( button => button . Name == "ScrollIncreaseButton" && button . IsEnabled ) &&
556+ view . TabItems [ 0 ] is TabViewItem { IsLoaded : true } first &&
557+ Bounds ( first , viewport ) is var bounds && bounds . Right > 0.5 && bounds . Left < viewport . ActualWidth - 0.5 ;
558+ } , "native overflow can scroll toward the hidden tabs" , ( ) => $ "offset={ Strip ( ) . HorizontalOffset } ") ) ;
559+ // TabView::OnScrollIncreaseClick starts a scroll 50 DIPs past the offset at the click, clamped to the end.
560+ // TabView's own delayed bring-into-view of the newly selected tab can cancel that scroll within milliseconds,
561+ // so prove the view change the arrow starts: an unclamped target within half a step of that 50-DIP step.
562+ // Bringing the first tab back into view from the start never targets that far.
563+ var targets = new System . Collections . Generic . List < double > ( ) ;
564+ var clickOffset = double . NaN ;
565+ await ui . RunOnUIAsync ( ( ) =>
566+ {
567+ var increase = FindDescendants < RepeatButton > ( FindControl < TabView > ( surface ! , "ConversationPanelTabs" ) )
568+ . Single ( button => button . Name == "ScrollIncreaseButton" ) ;
569+ Strip ( ) . ViewChanging += ( _ , args ) => targets . Add ( args . FinalView . HorizontalOffset ) ;
570+ increase . Click += ( _ , _ ) => clickOffset = Strip ( ) . HorizontalOffset ;
571+ Invoke ( increase ) ;
545572 } ) ;
546573 await ui . RunOnUIAsync ( ( ) => WaitForRenderedConditionAsync (
547- ( ) => FindDescendants < RepeatButton > ( FindControl < TabView > ( surface ! , "ConversationPanelTabs" ) )
548- . Any ( button => button . Name == "ScrollIncreaseButton" && button . IsEnabled ) ,
549- "native overflow can scroll toward the hidden tabs" ) ) ;
550- await ui . RunOnUIAsync ( ( ) => Invoke (
551- FindDescendants < RepeatButton > ( FindControl < TabView > ( surface ! , "ConversationPanelTabs" ) )
552- . Single ( button => button . Name == "ScrollIncreaseButton" ) ) ) ;
553- await ui . RunOnUIAsync ( ( ) => WaitForRenderedConditionAsync (
554- ( ) => FindDescendants < ScrollViewer > ( FindControl < TabView > ( surface ! , "ConversationPanelTabs" ) )
555- . Any ( scroll => scroll . HorizontalOffset > 0 ) ,
556- "native overflow arrow scrolls the tab strip" ) ) ;
574+ ( ) => clickOffset + 75 < Strip ( ) . ScrollableWidth &&
575+ targets . Any ( target => target > clickOffset + 25 && target <= clickOffset + 75 ) ,
576+ "native overflow arrow scrolls the tab strip" ,
577+ ( ) => $ "clickOffset={ clickOffset } , targets=[{ string . Join ( ", " , targets ) } ], scrollable={ Strip ( ) . ScrollableWidth } ") ) ;
557578 await ui . RunOnUIAsync ( ( ) =>
558579 {
559580 var view = FindControl < TabView > ( surface ! , "ConversationPanelTabs" ) ;
560581 Assert . Equal ( 5 , view . TabItems . Count ) ;
561582 Assert . Equal ( 5 , panels . Tabs . Count ) ;
562- view . SelectedItem = view . TabItems [ 0 ] ;
563583 Assert . Equal ( "files" , panels . Selected ) ;
564584 } ) ;
565585 }
0 commit comments