Skip to content

Conversation

@Renzo-Olivares
Copy link
Contributor

Fixes #150897

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • I followed the [breaking change policy] and added [Data Driven Fixes] where supported.
  • All existing and new tests are passing.

@github-actions github-actions bot added the framework flutter/packages/flutter repository. See also f: labels. label Jul 1, 2024
@Renzo-Olivares Renzo-Olivares changed the title fix scrolling conflicts Fix SelectionArea scrolling conflicts Jul 1, 2024
@Renzo-Olivares Renzo-Olivares requested a review from chunhtai July 1, 2024 21:42
@Renzo-Olivares
Copy link
Contributor Author

Friendly bump for review.


void _initMouseGestureRecognizer() {
switch (defaultTargetPlatform) {
case TargetPlatform.android:
Copy link
Contributor

Choose a reason for hiding this comment

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

nice clean up. I wonder why we have the switch case before

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I think I just forgot to remove it.

// A [TapAndHorizontalDragGestureRecognizer] is used on non-precise pointer devices
// like PointerDeviceKind.touch so [SelectableRegion] gestures do not conflict with
// ancestor Scrollable gestures in common scenarios like a vertically scrolling list view.
_gestureRecognizers[TapAndHorizontalDragGestureRecognizer] = GestureRecognizerFactoryWithHandlers<TapAndHorizontalDragGestureRecognizer>(
Copy link
Contributor

Choose a reason for hiding this comment

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

does the touch gesture support drag selection without tapping the selection gesture?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean a single tap followed by a drag? Touch devices do not support this only mouse. There is an existing check that looks for this

case 1:
if (details.kind != null && !_isPrecisePointerDevice(details.kind!)) {
// Drag to select is only enabled with a precise pointer device.
return;
}
and
case 1:
if (details.kind != null && !_isPrecisePointerDevice(details.kind!)) {
// Drag to select is only enabled with a precise pointer device.
return;
}
.

Copy link
Contributor

Choose a reason for hiding this comment

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

In that case, why do we need this TapAndHorizontalDragGestureRecognizer for non precision device?

Copy link
Contributor

Choose a reason for hiding this comment

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

also if the reason we use tap and horizontal drag is to not conflict with vertical scroll. wouldn't that still cause issues with horizontal scroll?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We still need to use TapAndHorizontalDragGestureRecognizer for touch devices to support consecutive tap + drag just not single tap + drag.

It would still cause an issue with horizontal scroll, but in most cases this is not an issue. Take Android as an example, the HorizontalScrollable will have a touchSlop of 8.0 derived from https://developer.android.com/reference/android/view/ViewConfiguration#getScaledTouchSlop(). In my observations I've seen this value mostly set to ~8.0 on Android devices. The SelectableRegions TapAndHorizontalDragGestureRecognizer uses the default 18.0 for touch slop, so the HorizontalScrollable will still be able to win.

In the case of iOS it is a little more tricky since there is no getScaledTouchSlop equivalent provided by the iOS platform, so the HorizontalScrollable will always default to 18.0 and that will match the default of SelectableRegions TapAndHorizontalDragGestureRecognizer. That is why on iOS we set eagerVictoryOnDrag to false, which means the recognizer will wait until it is the last one in the arena before declaring victory, allowing horizontal drags to go through.

Copy link
Contributor

Choose a reason for hiding this comment

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

will using this gesture recognizer causes weirdness when user tap and vertical select? Base on reading the doc it looks like it would only accept horizontal drag first before winning the arena.

If the issue is with the slop, could we fix the vertical conflict by increase or decrease the tapandPanGestureRecognizer as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It shouldn't cause weirdness with tap and vertical select, for example in the case of a double tap + vertical drag on Android or iOS, the TapAndHorizontalDragGestureRecognizer will declare victory on a consecutive tap

if (consecutiveTapCount > 1) {
// If our consecutive tap count is greater than 1, i.e. is a double tap or greater,
// then this recognizer declares victory to prevent the [LongPressGestureRecognizer]
// from declaring itself the winner if a double tap is held for too long.
resolve(GestureDisposition.accepted);
}
, so when the drag happens the recognizer has already won and will accept the drag in any direction.

I think the more we increase the slop the less responsive the selection gesture will feel. I don't think this is ideal since selection gestures will not always be used in a Scrollable. I explored this method with TextFields when fixing a similar issue and found it to be fragile.

Copy link
Contributor

Choose a reason for hiding this comment

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

sounds good to me then.

Copy link
Contributor

@chunhtai chunhtai left a comment

Choose a reason for hiding this comment

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

LGTM

// A [TapAndHorizontalDragGestureRecognizer] is used on non-precise pointer devices
// like PointerDeviceKind.touch so [SelectableRegion] gestures do not conflict with
// ancestor Scrollable gestures in common scenarios like a vertically scrolling list view.
_gestureRecognizers[TapAndHorizontalDragGestureRecognizer] = GestureRecognizerFactoryWithHandlers<TapAndHorizontalDragGestureRecognizer>(
Copy link
Contributor

Choose a reason for hiding this comment

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

sounds good to me then.

@mark8044
Copy link

Itching to get this onto my app for testing, how does it get past the Google testing?

@Renzo-Olivares Renzo-Olivares force-pushed the selection-area-scrolling-fixes branch from 8d731a0 to d22dee3 Compare July 18, 2024 21:01
@Renzo-Olivares Renzo-Olivares added the autosubmit Merge PR when tree becomes green via auto submit App label Jul 18, 2024
@auto-submit
Copy link
Contributor

auto-submit bot commented Jul 18, 2024

auto label is removed for flutter/flutter/151138, due to - The status or check suite Linux build_tests_2_3 has failed. Please fix the issues identified (or deflake) before re-applying this label.

@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jul 18, 2024
@Renzo-Olivares Renzo-Olivares added the autosubmit Merge PR when tree becomes green via auto submit App label Jul 18, 2024
@auto-submit auto-submit bot merged commit 93fd294 into flutter:master Jul 18, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 19, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 19, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 19, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 19, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 19, 2024
LouiseHsu pushed a commit to flutter/packages that referenced this pull request Jul 20, 2024
Roll Flutter from 58068d8 to 7d5c1c0 (104 revisions)

flutter/flutter@58068d8...7d5c1c0

2024-07-19 104349824+huycozy@users.noreply.github.com Enhances
intuitiveness of RawMagnifier's example (flutter/flutter#150308)
2024-07-19 137456488+flutter-pub-roller-bot@users.noreply.github.com
Roll pub packages (flutter/flutter#151992)
2024-07-19 32538273+ValentinVignal@users.noreply.github.com Add test for
scrollbar.1.dart (flutter/flutter#151463)
2024-07-19 engine-flutter-autoroll@skia.org Roll Flutter Engine from
ea1e53a4e810 to 969fb7abc449 (3 revisions) (flutter/flutter#152018)
2024-07-19 goderbauer@google.com docimports for rendering library
(flutter/flutter#151958)
2024-07-19 engine-flutter-autoroll@skia.org Roll Flutter Engine from
b65c93ea948e to ea1e53a4e810 (2 revisions) (flutter/flutter#152012)
2024-07-19 kevmoo@users.noreply.github.com painting: drop deprecated
(exported) hashList and hashValues functions (flutter/flutter#151677)
2024-07-18 engine-flutter-autoroll@skia.org Roll Flutter Engine from
766f7bed7185 to b65c93ea948e (2 revisions) (flutter/flutter#152004)
2024-07-18 magder@google.com Update TESTOWNERS (flutter/flutter#151907)
2024-07-18 n7484443@naver.com chore: fix test name & add description of
tests (flutter/flutter#151959)
2024-07-18 engine-flutter-autoroll@skia.org Roll Flutter Engine from
564ded4c4742 to 766f7bed7185 (2 revisions) (flutter/flutter#151998)
2024-07-18 rmolivares@renzo-olivares.dev Fix SelectionArea scrolling
conflicts (flutter/flutter#151138)
2024-07-18 rmolivares@renzo-olivares.dev Fix:
BaseTapAndDragGestureRecognizer should reset drag state after losing
gesture arena (flutter/flutter#151989)
2024-07-18 137456488+flutter-pub-roller-bot@users.noreply.github.com
Roll pub packages (flutter/flutter#151975)
2024-07-18 engine-flutter-autoroll@skia.org Roll Flutter Engine from
8bcf638eb893 to 564ded4c4742 (2 revisions) (flutter/flutter#151986)
2024-07-18 88094492+croro613@users.noreply.github.com Fix
WidgetStateTextStyle's doc (flutter/flutter#151935)
2024-07-18 engine-flutter-autoroll@skia.org Roll Flutter Engine from
d58ba74250ce to 8bcf638eb893 (2 revisions) (flutter/flutter#151977)
2024-07-18 kevinjchisholm@google.com Adds 3.22.3 changelog
(flutter/flutter#151974)
2024-07-18 engine-flutter-autoroll@skia.org Roll Packages from
d03b1b4 to c7f0526 (8 revisions) (flutter/flutter#151971)
2024-07-18 nate.w5687@gmail.com `WidgetState` mapping
(flutter/flutter#146043)
2024-07-18 greg@zulip.com Fix AppBar doc to keep diagram next to its
description (flutter/flutter#151937)
2024-07-18 greg@zulip.com Small fixes to Image docs: NNBD, and add a
cross-reference (flutter/flutter#151938)
2024-07-18 engine-flutter-autoroll@skia.org Roll Flutter Engine from
b043fe447bb3 to d58ba74250ce (1 revision) (flutter/flutter#151964)
2024-07-18 137456488+flutter-pub-roller-bot@users.noreply.github.com
Roll pub packages (flutter/flutter#151946)
2024-07-18 137456488+flutter-pub-roller-bot@users.noreply.github.com
Roll pub packages (flutter/flutter#151904)
2024-07-18 engine-flutter-autoroll@skia.org Roll Flutter Engine from
e3abca2d8105 to b043fe447bb3 (1 revision) (flutter/flutter#151942)
2024-07-18 engine-flutter-autoroll@skia.org Roll Flutter Engine from
8073523b4623 to e3abca2d8105 (1 revision) (flutter/flutter#151936)
2024-07-18 engine-flutter-autoroll@skia.org Roll Flutter Engine from
dfe22e3acc19 to 8073523b4623 (1 revision) (flutter/flutter#151934)
2024-07-18 engine-flutter-autoroll@skia.org Roll Flutter Engine from
184c3f0de6b3 to dfe22e3acc19 (1 revision) (flutter/flutter#151930)
2024-07-18 engine-flutter-autoroll@skia.org Roll Flutter Engine from
00f0f6b74da7 to 184c3f0de6b3 (1 revision) (flutter/flutter#151928)
2024-07-18 engine-flutter-autoroll@skia.org Roll Flutter Engine from
d194a2f0e5da to 00f0f6b74da7 (1 revision) (flutter/flutter#151927)
2024-07-18 engine-flutter-autoroll@skia.org Roll Flutter Engine from
a5a93bb80bd1 to d194a2f0e5da (3 revisions) (flutter/flutter#151925)
2024-07-17 engine-flutter-autoroll@skia.org Roll Flutter Engine from
e9dc62074c2b to a5a93bb80bd1 (1 revision) (flutter/flutter#151918)
2024-07-17 yjbanov@google.com [web] use the new backlog Github project
in triage links (flutter/flutter#151920)
2024-07-17 yjbanov@google.com Update Flutter-Web-Triage.md
(flutter/flutter#151607)
2024-07-17 leroux_bruno@yahoo.fr Reland fix InputDecorator hint default
text style on M3 (flutter/flutter#150835)
2024-07-17 engine-flutter-autoroll@skia.org Roll Flutter Engine from
39ee1a549581 to e9dc62074c2b (3 revisions) (flutter/flutter#151915)
2024-07-17 victorsanniay@gmail.com Constrain `CupertinoContextMenu`
animation to safe area (flutter/flutter#151860)
2024-07-17 36861262+QuncCccccc@users.noreply.github.com Create
`CarouselView` widget - Part 2 (flutter/flutter#149775)
2024-07-17 engine-flutter-autoroll@skia.org Roll Flutter Engine from
45b722b661f0 to 39ee1a549581 (3 revisions) (flutter/flutter#151905)
2024-07-17 34465683+rkishan516@users.noreply.github.com docs: Fix typo
in data driven fixes test folder section (flutter/flutter#151836)
2024-07-17 zanderso@users.noreply.github.com Stop running flaky mac
tests in presubmit (flutter/flutter#151870)
2024-07-17 engine-flutter-autoroll@skia.org Roll Flutter Engine from
7e2579634027 to 45b722b661f0 (1 revision) (flutter/flutter#151895)
2024-07-17 44146839+essjay05@users.noreply.github.com fix(Flutter Web
App): fixes html lang typo (flutter/flutter#151866)
2024-07-17 matanlurey@users.noreply.github.com Delete `docs/engine`
directory (flutter/flutter#151616)
2024-07-17 31859944+LongCatIsLooong@users.noreply.github.com Make
`CupertinoSlidingSegmentedControl` type parameter non-null
(flutter/flutter#151803)
...
Renzo-Olivares added a commit to Renzo-Olivares/flutter that referenced this pull request Jul 27, 2024
auto-submit bot pushed a commit that referenced this pull request Jul 27, 2024
Fixes `SelectionArea`/`SelectableRegion` scrolling jank when a `SelectionArea`/`SelectableRegion` is used as a child of a `Scrollable` like `ListView` or `PageView`.

Fixes #152420

Cherry-pick of: #151138

Related issue: #150897
TytaniumDev pushed a commit to TytaniumDev/flutter that referenced this pull request Aug 7, 2024
Buchimi pushed a commit to Buchimi/flutter that referenced this pull request Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SelectionArea intermittently interferes with listview scrolling (and possibly other scrolls)

3 participants