Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/src/act/act.dart
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,11 @@ class Act {

// Take the closest Scrollable above the dragStart widget. This is the
// widget which makes a widget scrollable. It must always exist.
final WidgetSelector<Scrollable> scrollable =
spot<Scrollable>().withChild(dragStart).last();
// If dragStart is already a Scrollable, use it directly instead of searching for a parent.
final WidgetSelector<Scrollable> scrollable = switch (dragStart) {
final WidgetSelector<Scrollable> s => s,
_ => spot<Scrollable>().withChild(dragStart).last(),
};

// Save the 'Element' of the currently targeted Scrollable.
// This ensures that—even if multiple scrollables exist or the
Expand Down
25 changes: 25 additions & 0 deletions test/act/act_drag_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,31 @@ void dragTests() {
await act.tap(secondItem);
},
);

testWidgets(
'Finds widget in vertical ListView after dragging when dragStart is a Scrollable',
(tester) async {
await tester.pumpWidget(
const DragUntilVisibleSingleDirectionTestWidget(
axis: Axis.vertical,
ignorePointerAtIndices: [0, 1, 2, 3, 4, 5, 6, 7, 8],
),
);

final firstItem = spot<DragUntilVisibleSingleDirectionTestWidget>()
.spot<Scrollable>()
.last()
..existsOnce();
final secondItem = spotText('Item at index: 27', exact: true)
..doesNotExist();
await act.dragUntilVisible(
dragStart: firstItem,
dragTarget: secondItem,
maxIteration: 30,
);
secondItem.existsOnce();
},
);
});

group('Horizontal Drag', () {
Expand Down
Loading