Skip to content

Fix RangeSlider thumb overlay remains visible after touch interaction… - #189610

Closed
KarthikManikuttan wants to merge 17 commits into
flutter:masterfrom
KarthikManikuttan:fix-range-slider-touch-overlay-clean
Closed

KarthikManikuttan wants to merge 17 commits into
flutter:masterfrom
KarthikManikuttan:fix-range-slider-touch-overlay-clean

Conversation

@KarthikManikuttan

Copy link
Copy Markdown

Fixes #189205

This PR fixes RangeSlider overlay behavior for touch interactions.

After a RangeSlider thumb was touched or dragged, the selected thumb could retain focus and continue painting the focused overlay after the touch gesture ended. This happened because the focused thumb requested keyboard focus during pointer interaction, and RangeSlider painted its focused overlay directly from FocusNode.hasFocus.

This PR separates actual thumb focus from the visual focus highlight. Touch interaction can still move focus to the selected thumb for semantics and keyboard continuation, but the focused overlay is only painted when Flutter’s focus highlight mode says it should be shown, such as keyboard/traditional focus.

This PR also fixes the active drag overlay disappearing while a touch gesture is still in progress. Previously, if the finger moved outside the thumb’s overlay bounds during a drag, hover tracking could reverse the shared overlay animation even though the slider was still active. The overlay now remains visible for the active drag and dismisses when the interaction ends.

Changes:

  • Uses FocusableActionDetector for the start and end thumb focus nodes.
  • Tracks visual focus highlight state separately for each thumb.
  • Paints focused overlays from focus-highlight state instead of raw focus ownership.
  • Keeps semantics focused state based on the real thumb focus nodes.
  • Keeps the active drag overlay visible while _RenderRangeSlider is actively interacting.
  • Updates stale paint expectations that assumed a post-touch overlay remained.
  • Adds regression tests for touch focus, keyboard focus, and active drag overlay behavior.

Tests added/updated:

  • RangeSlider keeps drag overlay when touch moves outside thumb
  • RangeSlider touch focus does not show persistent overlay
  • RangeSlider keyboard focus shows focused overlay

Validation:

  • dart format packages/flutter/lib/src/material/range_slider.dart packages/flutter/test/material/range_slider_test.dart
  • flutter test packages/flutter/test/material/range_slider_test.dart

The targeted range_slider_test.dart suite passes locally.

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

@github-actions github-actions Bot added framework flutter/packages/flutter repository. See also f: labels. p: material_ui material_ui package in flutter/packages labels Jul 16, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the RangeSlider component to correctly handle focus highlights for its start and end thumbs by replacing the existing Focus widgets with FocusableActionDetector and managing focus states via new state variables. The changes include updates to the render object to support these focus states and the addition of new test cases to verify the focus behavior. The reviewer suggests refactoring the duplicated FocusableActionDetector logic into a private helper method to improve maintainability.

@dkwingsmt
dkwingsmt requested a review from QuncCccccc July 22, 2026 18:17
@QuncCccccc QuncCccccc added the CICD Run CI/CD label Jul 22, 2026

@QuncCccccc QuncCccccc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix looks really good! Thanks for your contribution! Just left a few comments:)

@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Jul 23, 2026

@KarthikManikuttan KarthikManikuttan left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@QuncCccccc Thanks for the review comments, I updated the PR

waiting for your comments 😊

@QuncCccccc QuncCccccc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for your quick response! Overall LGTM with just one more test comment!

@KarthikManikuttan KarthikManikuttan left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@QuncCccccc Thank you for the review, I added a focused-state customization test
If there is anything else , please comment 😊

@QuncCccccc QuncCccccc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for your quick update!

@victorsanni victorsanni left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

@victorsanni

Copy link
Copy Markdown
Contributor

Google testing failures look expected to me, image diffs where the reference image shows one thumb with a lingering highlight and the test image shows the highlight gone.

@KarthikManikuttan

Copy link
Copy Markdown
Author

@QuncCccccc @victorsanni Thanks for confirming. Since the Google testing failures are expected golden/image diffs from removing the lingering RangeSlider focus highlight, could you please approve/triage the Google testing result or add the PR to the Google testing queue?

@QuncCccccc

Copy link
Copy Markdown
Contributor

This PR is good to go but we are still in code freeze for Material and Cupertino library. I'll mark this as Draft and add "wait for code freeze" for now. Later when material_ui starts to accept contribution, we will provide instructions about how to move these fixes over there! Thanks a lot!

@QuncCccccc
QuncCccccc marked this pull request as draft July 24, 2026 18:19
@QuncCccccc QuncCccccc added the waiting for code freeze This PR is waiting for a code freeze to resolve. label Jul 24, 2026
@github-actions

Copy link
Copy Markdown

This pull request contains changes to Material or Cupertino, which are currently frozen in this repository.

Changes should be made in material_ui and/or cupertino_ui in the flutter/packages repository.

Please refer to #188444 for instructions.

@KarthikManikuttan

Copy link
Copy Markdown
Author

@QuncCccccc Hi! I saw the new instructions for porting Material/Cupertino PRs to flutter/packages. Is #189610 ready to be ported to material_ui now, or should I wait for any further guidance?

@QuncCccccc

Copy link
Copy Markdown
Contributor

Is #189610 ready to be ported to material_ui now

Hi @KarthikManikuttan, yes, I just LGTMed the ported one. So I'm closing this one. Thanks for the help:)!

@QuncCccccc QuncCccccc closed this Aug 24, 2026
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Aug 24, 2026
… ends (#12560)

Ports flutter/flutter#189610 to material_ui, per the porting instructions in flutter/flutter#188444.

Fixes flutter/flutter#189205

After a RangeSlider thumb was touched or dragged, the selected thumb could retain focus and continue painting the focused overlay after the touch gesture ended. This happened because the focused thumb requested keyboard focus during pointer interaction, and RangeSlider painted its focused overlay directly from FocusNode.hasFocus.

This PR separates actual thumb focus from the visual focus highlight. Touch interaction can still move focus to the selected thumb for semantics and keyboard continuation, but the focused overlay is only painted when Flutter's focus highlight mode says it should be shown, such as keyboard/traditional focus.

This PR also fixes the active drag overlay disappearing while a touch gesture is still in progress. Previously, if the finger moved outside the thumb's overlay bounds during a drag, hover tracking could reverse the shared overlay animation even though the slider was still active. The overlay now remains visible for the active drag and dismisses when the interaction ends.

Original PR: flutter/flutter#189610

## Pre-Review Checklist
jagadeesh8682 pushed a commit to jagadeesh8682/packages that referenced this pull request Sep 2, 2026
… ends (flutter#12560)

Ports flutter/flutter#189610 to material_ui, per the porting instructions in flutter/flutter#188444.

Fixes flutter/flutter#189205

After a RangeSlider thumb was touched or dragged, the selected thumb could retain focus and continue painting the focused overlay after the touch gesture ended. This happened because the focused thumb requested keyboard focus during pointer interaction, and RangeSlider painted its focused overlay directly from FocusNode.hasFocus.

This PR separates actual thumb focus from the visual focus highlight. Touch interaction can still move focus to the selected thumb for semantics and keyboard continuation, but the focused overlay is only painted when Flutter's focus highlight mode says it should be shown, such as keyboard/traditional focus.

This PR also fixes the active drag overlay disappearing while a touch gesture is still in progress. Previously, if the finger moved outside the thumb's overlay bounds during a drag, hover tracking could reverse the shared overlay animation even though the slider was still active. The overlay now remains visible for the active drag and dismisses when the interaction ends.

Original PR: flutter/flutter#189610

## Pre-Review Checklist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

f: material design framework flutter/packages/flutter repository. See also f: labels. p: material_ui material_ui package in flutter/packages waiting for code freeze This PR is waiting for a code freeze to resolve.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RangeSlider thumb overlay remains visible after touch interaction ends on mobile

3 participants