Skip to content

fix(ui): jump on text selection - #2864

Merged
renefloor merged 2 commits into
masterfrom
fix/jump-on-text-selection
Aug 4, 2026
Merged

fix(ui): jump on text selection#2864
renefloor merged 2 commits into
masterfrom
fix/jump-on-text-selection

Conversation

@renefloor

@renefloor renefloor commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Submit a pull request

Github Issue: fixes #2862

CLA

  • I have signed the Stream CLA (required).
  • The code changes follow best practices
  • Code changes are tested (add some information if not applicable)

Description of the pull request

This PR fixes the specific case of text selection, but we might want a better fix.

Summary by CodeRabbit

  • Bug Fixes

    • Fixed desktop and web text selection causing StreamMessageListView to jump multiple screens.
    • Improved item reveal behavior for standard, reversed, and shrink-wrapped lists.
    • Prevented repeated reveal operations from causing unintended scrolling.
  • Tests

    • Added coverage for anchor-aware scrolling, exact item reveals, repeated reveals, and text selection behavior.

@renefloor renefloor changed the title fixes jump on text selection fix(ui): jump on text selection Aug 4, 2026
@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 1750517b-5aea-42f8-a700-ecc20042c5c5

📥 Commits

Reviewing files that changed from the base of the PR and between afc6643 and e07290b.

📒 Files selected for processing (2)
  • packages/stream_chat_flutter/lib/scrollable_positioned_list/src/wrapping.dart
  • packages/stream_chat_flutter/test/scrollable_positioned_list/reveal_anchor_test.dart
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/stream_chat_flutter/lib/scrollable_positioned_list/src/wrapping.dart

📝 Walkthrough

Walkthrough

The PR adds anchor-aware viewport reveal corrections, removes duplicate anchor adjustments from ScrollablePositionedList, and adds tests for normal, reversed, shrink-wrapped, repeated, and text-selection reveal behavior.

Changes

Anchor-aware reveal behavior

Layer / File(s) Summary
Viewport reveal corrections
packages/stream_chat_flutter/lib/scrollable_positioned_list/src/viewport.dart, packages/stream_chat_flutter/lib/scrollable_positioned_list/src/wrapping.dart
Custom viewports correct reveal offsets and rectangles for anchor displacement, axis direction, zero anchors, and non-finite results.
ScrollablePositionedList reveal integration
packages/stream_chat_flutter/lib/scrollable_positioned_list/src/positioned_list.dart
The list removes duplicate anchor calculations and uses reveal offsets relative to the current viewport pixels.
Reveal validation and changelog
packages/stream_chat_flutter/test/scrollable_positioned_list/reveal_anchor_test.dart, packages/stream_chat_flutter/CHANGELOG.md
Widget tests cover anchored, reversed, shrink-wrapped, repeated, and text-selection reveals. The changelog records the fix.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant SelectableText
  participant ScrollablePositionedList
  participant AnchoredViewport
  SelectableText->>ScrollablePositionedList: request showOnScreen
  ScrollablePositionedList->>AnchoredViewport: request getOffsetToReveal
  AnchoredViewport-->>ScrollablePositionedList: return corrected offset and rectangle
  ScrollablePositionedList-->>SelectableText: preserve the target reveal position
Loading

Possibly related PRs

Suggested reviewers: xsahil03x

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the primary fix for unexpected UI jumping during text selection.
Linked Issues check ✅ Passed The changes address anchor-aware reveal behavior that caused unexpected channel scrolling during selectable message text interactions in issue #2862.
Out of Scope Changes check ✅ Passed The viewport fixes, regression tests, and changelog entry are directly related to preventing unintended scrolling during text selection.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/jump-on-text-selection

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai 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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@packages/stream_chat_flutter/lib/scrollable_positioned_list/src/wrapping.dart`:
- Around line 159-170: Update the reveal correction in getOffsetToReveal to use
the layout main-axis extent supplied to _attemptLayout rather than size,
especially for shrinkWrap layouts. Store that _attemptLayout extent on the
relevant state/object and use it for the anchor-based offset and rect
adjustment, preserving the existing finite-offset and zero-correction guards.

In
`@packages/stream_chat_flutter/test/scrollable_positioned_list/reveal_anchor_test.dart`:
- Around line 145-163: Register teardown to restore
debugDefaultTargetPlatformOverride before setting it to TargetPlatform.macOS in
this test, ensuring cleanup runs if pump, gesture operations, or the expectation
throws; remove reliance on the manual reset at the test body’s end.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 3cc7e448-f9c6-4ad0-b67e-75920312ab00

📥 Commits

Reviewing files that changed from the base of the PR and between 1616091 and afc6643.

📒 Files selected for processing (5)
  • packages/stream_chat_flutter/CHANGELOG.md
  • packages/stream_chat_flutter/lib/scrollable_positioned_list/src/positioned_list.dart
  • packages/stream_chat_flutter/lib/scrollable_positioned_list/src/viewport.dart
  • packages/stream_chat_flutter/lib/scrollable_positioned_list/src/wrapping.dart
  • packages/stream_chat_flutter/test/scrollable_positioned_list/reveal_anchor_test.dart

@codecov

codecov Bot commented Aug 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 82.60870% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.87%. Comparing base (1616091) to head (e07290b).

Files with missing lines Patch % Lines
...r/lib/scrollable_positioned_list/src/viewport.dart 80.00% 2 Missing ⚠️
...r/lib/scrollable_positioned_list/src/wrapping.dart 83.33% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2864      +/-   ##
==========================================
+ Coverage   72.86%   72.87%   +0.01%     
==========================================
  Files         429      429              
  Lines       27698    27716      +18     
==========================================
+ Hits        20183    20199      +16     
- Misses       7515     7517       +2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@renefloor
renefloor merged commit 0ec7ee3 into master Aug 4, 2026
28 checks passed
@renefloor
renefloor deleted the fix/jump-on-text-selection branch August 4, 2026 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unexpected scrolling when tapping selectable message text on macOS

2 participants