Fix ToggleSwitch knob touching track boundary during drag - #11659
Open
Rashmi Thakur (rashmi-thakurr) wants to merge 2 commits into
Open
Fix ToggleSwitch knob touching track boundary during drag#11659Rashmi Thakur (rashmi-thakurr) wants to merge 2 commits into
Rashmi Thakur (rashmi-thakurr) wants to merge 2 commits into
Conversation
Keep the expanded pressed knob within the track during drag without changing the translation range used for toggle behavior and animations. Add integration coverage for both Off and On drag directions. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 52fc8e81-8915-40ba-9160-2826b6a549e7
Measure the visible knob inset in the knob container's coordinate space and strengthen the boundary regression with full-range drags. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 52fc8e81-8915-40ba-9160-2826b6a549e7
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Rashmi Thakur (rashmi-thakurr)
marked this pull request as ready for review
August 26, 2026 14:26
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes
Fixes #10822
PR Type
Description
Current Behavior
While dragging a
ToggleSwitch, the expanded pressed knob can touch the track boundary at the hard drag endpoint. The behavior is especially visible when the switch starts in the On state and is dragged toward Off.New Behavior
The visible knob preserves its resting inset from the track boundary throughout a drag, including at both hard endpoints and regardless of whether the switch starts On or Off.
The drag logic now measures the visible state-specific knob (
SwitchKnobOfforSwitchKnobOn) in theSwitchKnobcontainer coordinate space and applies separate visual-only clamp bounds. The logical translation bounds, toggle thresholds, animation offsets, and state transitions remain unchanged. Custom templates without the optional visual parts retain the previous behavior.A regression test performs oversized drags in both directions and verifies the visible knob geometry rather than only the knob container geometry.
Customer Impact
This fixes a user-visible graphical issue where the ToggleSwitch knob could appear flush against or overlap the track boundary while the pointer remained held during a drag.
Regression Potential
The adjustment is isolated to ToggleSwitch drag-time visual clamping. It does not change public APIs or the logical values used to determine toggle state.
How Has This Been Tested?
Validation completed:
Microsoft.ui.xaml.vcxprojfor x64 CHK.Microsoft.UI.Xaml.Tests.External.Controls.vcxprojfor x64 CHK.KnobMaintainsMarginsFromTrackDuringDragfor initially-Off and initially-On hard drag endpoints.CanDragHorizontallyOverToggleSwitchToSelectmouse-drag test.mainbaseline in the same environment.Screenshots (if appropriate)
Before
20251006-2254-06.9878498.mp4
After
togglebutton-fix.mp4