mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Add hitTestChildren to baseline-aligned stack (#172485)
Fixes http://github.com/flutter/flutter/issues/171510
This commit is contained in:
parent
3ceb2e0a48
commit
6a3ebfe3f3
@ -1878,4 +1878,20 @@ class _RenderBaselineAlignedStack extends RenderBox
|
||||
assert(size.isFinite);
|
||||
return constraints.constrain(size);
|
||||
}
|
||||
|
||||
@override
|
||||
bool hitTestChildren(BoxHitTestResult result, {required Offset position}) {
|
||||
final RenderBox editableText = _editableTextChild;
|
||||
final _BaselineAlignedStackParentData editableTextParentData =
|
||||
editableText.parentData! as _BaselineAlignedStackParentData;
|
||||
|
||||
return result.addWithPaintOffset(
|
||||
offset: editableTextParentData.offset,
|
||||
position: position,
|
||||
hitTest: (BoxHitTestResult result, Offset transformed) {
|
||||
assert(transformed == position - editableTextParentData.offset);
|
||||
return editableText.hitTest(result, position: transformed);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -10462,6 +10462,19 @@ void main() {
|
||||
await performBaselineAlignmentCheck(20.0, 40.0);
|
||||
});
|
||||
|
||||
testWidgets('Editable text in text field with placeholder is hit-testable', (
|
||||
WidgetTester tester,
|
||||
) async {
|
||||
await tester.pumpWidget(
|
||||
const CupertinoApp(
|
||||
home: Center(child: CupertinoTextField(placeholder: 'placeholder')),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.byType(CupertinoTextField), findsOneWidget);
|
||||
expect(find.byType(EditableText).hitTestable(), findsOne);
|
||||
});
|
||||
|
||||
testWidgets('Start the floating cursor on long tap', (WidgetTester tester) async {
|
||||
EditableText.debugDeterministicCursor = true;
|
||||
final TextEditingController controller = TextEditingController(text: 'abcd');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user