Skip to content

Commit 7cf2989

Browse files
Mitigate issue by skipping animation when IsHitTestVisible == False
1 parent da39b20 commit 7cf2989

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/MaterialDesignThemes.Wpf/Behaviors/Internal/TabControlHeaderScrollBehavior.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -336,13 +336,14 @@ private void AssociatedObject_ScrollChanged(object sender, ScrollChangedEventArg
336336
return;
337337
if ( _isAnimatingScroll || _desiredScrollStart is not { } desiredOffsetStart)
338338
return;
339+
if (!TabControl.IsHitTestVisible)
340+
return;
339341

340342
double originalValue = desiredOffsetStart;
341343
double newValue = e.HorizontalOffset;
342344
_isAnimatingScroll = true;
343345

344346
// HACK: Temporarily disable user interaction while the animated scroll is ongoing. This prevents the double-click of a tab stopping the animation prematurely.
345-
bool originalIsHitTestVisibleValue = TabControl.IsHitTestVisible;
346347
TabControl.SetCurrentValue(FrameworkElement.IsHitTestVisibleProperty, false);
347348

348349
AssociatedObject.ScrollToHorizontalOffset(originalValue);
@@ -355,8 +356,8 @@ private void AssociatedObject_ScrollChanged(object sender, ScrollChangedEventArg
355356
_desiredScrollStart = null;
356357
_isAnimatingScroll = false;
357358

358-
// HACK: Set the hit test visibility back to its original value
359-
TabControl.SetCurrentValue(FrameworkElement.IsHitTestVisibleProperty, originalIsHitTestVisibleValue);
359+
// HACK: Re-enable hit test visibility
360+
TabControl.SetCurrentValue(FrameworkElement.IsHitTestVisibleProperty, true);
360361
};
361362
AssociatedObject.BeginAnimation(TabControlHeaderScrollBehavior.CustomHorizontalOffsetProperty, scrollAnimation);
362363
}

0 commit comments

Comments
 (0)