Skip to content

Conversation

@victorsanni
Copy link
Contributor

@victorsanni victorsanni commented Aug 13, 2024

Finishes the work started by @Kavantix in #110733.

Fixes Tapping items is not working in CupertinoPicker.

Before:

flutter.before.tap.picker.mov

After:

flutter.tap.picker.mov

Native picker:

native.tap.picker.mov

Pre-launch Checklist

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

@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. f: cupertino flutter/packages/flutter/cupertino repository labels Aug 13, 2024
@victorsanni victorsanni marked this pull request as ready for review August 13, 2024 18:49
@victorsanni victorsanni marked this pull request as draft August 13, 2024 19:08
@flutter-dashboard
Copy link

This pull request has been changed to a draft. The currently pending flutter-gold status will not be able to resolve until a new commit is pushed or the change is marked ready for review again.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@victorsanni victorsanni marked this pull request as ready for review August 13, 2024 22:40
Copy link
Contributor

@MitchellGoodwin MitchellGoodwin left a comment

Choose a reason for hiding this comment

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

LGTM!

Comment on lines 324 to 328
// If a controller is provided for this widget, it is
// expected to handle its own tap to scroll behavior.
onTappedChild: (widget.scrollController == null)
? (int index) => _handleChildTap(index, controller)
: null,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why can't we support the user provided scroll controller?

Copy link
Contributor

Choose a reason for hiding this comment

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

From a separate thread: doing so on the user provided scroll controller might conflict with their own implementation.
I wonder if we have an example of such a conflict?

Copy link
Contributor Author

@victorsanni victorsanni Aug 16, 2024

Choose a reason for hiding this comment

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

I'm increasingly believing there is a gesture conflict that is causing tests in date picker to fail.

Take this date picker test for example, along with the changes in this PR:

With tester.drag
testWidgets('TimerPicker minDate - maxDate with minuteInterval',
      (WidgetTester tester) async {
    DateTime date = DateTime.now();
    final DateTime minimum = DateTime(2022, 6, 14, 3, 31);
    final DateTime initial = DateTime(2022, 6, 14, 3, 40);
    final DateTime maximum = DateTime(2022, 6, 14, 3, 49);
    await tester.pumpWidget(
      CupertinoApp(
        home: Center(
          child: SizedBox(
            height: 400.0,
            width: 400.0,
            child: CupertinoDatePicker(
              initialDateTime: initial,
              minimumDate: minimum,
              maximumDate: maximum,
              minuteInterval: 5,
              use24hFormat: true,
              onDateTimeChanged: (DateTime newDate) {
                date = newDate;
                print('hiii');
              },
            ),
          ),
        ),
      ),
    );

    // Drag picker minutes to min date
     await tester.drag(find.text('40'), const Offset(0.0, 1000.0), touchSlopY: 0.0);
     await tester.pumpAndSettle();

    // Returns to min date.
    expect(
      date,
      DateTime(2022, 6, 14, 3, 35),
    );
  });

This test fails with the changes in this PR when tester.drag is used. However, it passes when tester.trackpadFling is used instead:

With tester.trackpadFling
testWidgets('TimerPicker minDate - maxDate with minuteInterval',
      (WidgetTester tester) async {
    DateTime date = DateTime.now();
    final DateTime minimum = DateTime(2022, 6, 14, 3, 31);
    final DateTime initial = DateTime(2022, 6, 14, 3, 40);
    final DateTime maximum = DateTime(2022, 6, 14, 3, 49);
    await tester.pumpWidget(
      CupertinoApp(
        home: Center(
          child: SizedBox(
            height: 400.0,
            width: 400.0,
            child: CupertinoDatePicker(
              initialDateTime: initial,
              minimumDate: minimum,
              maximumDate: maximum,
              minuteInterval: 5,
              use24hFormat: true,
              onDateTimeChanged: (DateTime newDate) {
                date = newDate;
                print('hiii');
              },
            ),
          ),
        ),
      ),
    );

    // Drag picker minutes to min date
    await tester.trackpadFling(find.text('40'), const Offset(0.0, 1000.0), 0.1);
    await tester.pumpAndSettle();

    // Returns to min date.
    expect(
      date,
      DateTime(2022, 6, 14, 3, 35),
    );
  });

The documentation for tester.trackpadFling says:

A trackpad fling sends PointerPanZoom events instead of a sequence of touch events.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From a separate thread: The scrollable used by CupertinoPicker has default drag start behavior DragStartBehavior.start. The documentation for tester.drag says:

Breaking the drag into multiple moves is necessary for accurate execution of drag update calls with a DragStartBehavior variable set to DragStartBehavior.start. Without such a change, the dragUpdate callback from a drag recognizer will never be invoked.

But the tests in date_picker.dart only uses one drag move.

@github-actions github-actions bot added the d: api docs Issues with https://api.flutter.dev/ label Aug 19, 2024
@victorsanni victorsanni marked this pull request as draft August 20, 2024 18:35
@victorsanni victorsanni force-pushed the enable-cupertino-picker-tap branch from 2fcbf75 to 44e6c1e Compare August 20, 2024 19:26
@github-actions github-actions bot removed f: scrolling Viewports, list views, slivers, etc. d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos labels Aug 20, 2024
@github-actions github-actions bot added the f: scrolling Viewports, list views, slivers, etc. label Aug 20, 2024
@victorsanni victorsanni marked this pull request as ready for review August 20, 2024 19:35
@victorsanni victorsanni added autosubmit Merge PR when tree becomes green via auto submit App and removed will affect goldens Changes to golden files labels Aug 20, 2024
@auto-submit auto-submit bot merged commit c631ad9 into flutter:master Aug 20, 2024
@victorsanni victorsanni deleted the enable-cupertino-picker-tap branch August 20, 2024 20:30
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 21, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 21, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 21, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 21, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 21, 2024
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Aug 21, 2024
flutter/flutter@e7da16d...b8f89f7

2024-08-21 [email protected] docs: Update doc for scale behaviour of floating label (flutter/flutter#151835)
2024-08-21 [email protected] Disable Dropdown menu search during keyboard navigation (flutter/flutter#152378)
2024-08-21 [email protected] Add a `bin/flutter-dev` script, for running the `flutter` command-line tool from source (flutter/flutter#153599)
2024-08-21 [email protected] Roll Packages from 4d2d2e3 to 4e5d47e (6 revisions) (flutter/flutter#153848)
2024-08-21 [email protected] Remove unnecessary breaks in default clauses of switch statements (flutter/flutter#153843)
2024-08-21 [email protected] Create Postmortem-Platform-View-android-14-regression (flutter/flutter#149201)
2024-08-21 [email protected] Roll pub packages (flutter/flutter#153838)
2024-08-21 [email protected] Roll pub packages (flutter/flutter#153833)
2024-08-21 [email protected] Add tests for `SingleChildScrollView` examples (flutter/flutter#153548)
2024-08-21 [email protected] Roll Flutter Engine from b1220aa0ebf2 to b94e0097035d (3 revisions) (flutter/flutter#153817)
2024-08-21 [email protected] Roll Flutter Engine from aa1422391cf6 to b1220aa0ebf2 (1 revision) (flutter/flutter#153810)
2024-08-21 [email protected] Roll Flutter Engine from a6508d6557dc to aa1422391cf6 (2 revisions) (flutter/flutter#153808)
2024-08-21 [email protected] Roll Flutter Engine from 5cbf96d0a80f to a6508d6557dc (1 revision) (flutter/flutter#153806)
2024-08-21 [email protected] Roll Flutter Engine from 3d18f65c378a to 5cbf96d0a80f (3 revisions) (flutter/flutter#153804)
2024-08-21 [email protected] `_InteractiveViewerState` code cleanup (flutter/flutter#153645)
2024-08-20 [email protected] Roll Flutter Engine from b80c831e03f7 to 3d18f65c378a (1 revision) (flutter/flutter#153797)
2024-08-20 [email protected] Fix leaky test. (flutter/flutter#153798)
2024-08-20 [email protected] Fix leaky tests. (flutter/flutter#153786)
2024-08-20 [email protected] Roll Flutter Engine from 663176175b4c to b80c831e03f7 (1 revision) (flutter/flutter#153789)
2024-08-20 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Update template/test `compileSdk`, `targetSdk`, `ndk` versions (#152487)" (flutter/flutter#153793)
2024-08-20 [email protected] Update template/test `compileSdk`, `targetSdk`, `ndk` versions (flutter/flutter#152487)
2024-08-20 [email protected] add autofocus to fix a11y issue with dialog (flutter/flutter#152637)
2024-08-20 [email protected] [Release] Update bots to expect new entitlements (flutter/flutter#153787)
2024-08-20 [email protected] Roll Flutter Engine from d6bc4dc6e59d to 663176175b4c (1 revision) (flutter/flutter#153785)
2024-08-20 [email protected] Roll pub packages (flutter/flutter#153740)
2024-08-20 [email protected] Implement tap to scroll to item in CupertinoPicker (flutter/flutter#153386)
2024-08-20 [email protected] Fix leaky test. (flutter/flutter#153780)
2024-08-20 [email protected] Roll Flutter Engine from e10b07598091 to d6bc4dc6e59d (2 revisions) (flutter/flutter#153781)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 11, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 12, 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 f: cupertino flutter/packages/flutter/cupertino repository f: scrolling Viewports, list views, slivers, etc. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tapping items is not working in CupertinoPicker

4 participants