fix a widgetspan hittest bug (#68694)
This commit is contained in:
parent
6a434ab9ec
commit
1bd661f4d4
@ -434,7 +434,8 @@ class RenderParagraph extends RenderBox
|
||||
@override
|
||||
bool hitTestChildren(BoxHitTestResult result, { required Offset position }) {
|
||||
RenderBox? child = firstChild;
|
||||
while (child != null) {
|
||||
int childIndex = 0;
|
||||
while (child != null && childIndex < _textPainter.inlinePlaceholderBoxes!.length) {
|
||||
final TextParentData textParentData = child.parentData! as TextParentData;
|
||||
final Matrix4 transform = Matrix4.translationValues(
|
||||
textParentData.offset.dx,
|
||||
@ -461,6 +462,7 @@ class RenderParagraph extends RenderBox
|
||||
return true;
|
||||
}
|
||||
child = childAfter(child);
|
||||
childIndex += 1;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -161,6 +161,42 @@ void main() {
|
||||
expect(tester.takeException(), null);
|
||||
}, skip: isBrowser); // https://github.com/flutter/flutter/issues/42086
|
||||
|
||||
testWidgets('inline widgets hitTest works with ellipsis', (WidgetTester tester) async {
|
||||
// Regression test for https://github.com/flutter/flutter/issues/68559
|
||||
const TextStyle textStyle = TextStyle(fontFamily: 'Ahem');
|
||||
await tester.pumpWidget(
|
||||
Text.rich(
|
||||
TextSpan(
|
||||
children: <InlineSpan>[
|
||||
const TextSpan(
|
||||
text: 'a very very very very very very very very very very long line',
|
||||
),
|
||||
WidgetSpan(
|
||||
child: SizedBox(
|
||||
width: 20,
|
||||
height: 40,
|
||||
child: Card(
|
||||
child: RichText(
|
||||
text: const TextSpan(text: 'widget should be truncated'),
|
||||
textDirection: TextDirection.rtl,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
style: textStyle,
|
||||
),
|
||||
textDirection: TextDirection.ltr,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
);
|
||||
|
||||
await tester.tap(find.byType(Text));
|
||||
|
||||
expect(tester.takeException(), null);
|
||||
}, skip: isBrowser); // https://github.com/flutter/flutter/issues/42086
|
||||
|
||||
testWidgets('inline widgets works with textScaleFactor', (WidgetTester tester) async {
|
||||
// Regression test for https://github.com/flutter/flutter/issues/59316
|
||||
final UniqueKey key = UniqueKey();
|
||||
|
Loading…
x
Reference in New Issue
Block a user