Unverified Commit 90afc5e8 authored by Tomasz Gucio's avatar Tomasz Gucio Committed by GitHub

Take paint offset into account for Editable children (#127843)

parent 2f521a21
......@@ -2459,7 +2459,7 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin,
}
_textPainter.paint(context.canvas, effectiveOffset);
paintInlineChildren(context, offset);
paintInlineChildren(context, effectiveOffset);
if (foregroundChild != null) {
context.paintChild(foregroundChild, offset);
......
......@@ -1558,6 +1558,45 @@ void main() {
expect(composingRect, null);
}, skip: isBrowser); // https://github.com/flutter/flutter/issues/61021
test('WidgetSpan render box is painted at correct offset when scrolled', () async {
final TextSelectionDelegate delegate = _FakeEditableTextState()
..textEditingValue = const TextEditingValue(
text: 'test',
selection: TextSelection.collapsed(offset: 3),
);
final List<RenderBox> renderBoxes = <RenderBox>[
RenderParagraph(const TextSpan(text: 'b'), textDirection: TextDirection.ltr),
];
final ViewportOffset viewportOffset = ViewportOffset.fixed(100.0);
final RenderEditable editable = RenderEditable(
backgroundCursorColor: Colors.grey,
selectionColor: Colors.black,
textDirection: TextDirection.ltr,
cursorColor: Colors.red,
offset: viewportOffset,
textSelectionDelegate: delegate,
startHandleLayerLink: LayerLink(),
endHandleLayerLink: LayerLink(),
maxLines: null,
text: TextSpan(
style: const TextStyle(height: 1.0, fontSize: 10.0),
children: <InlineSpan>[
const TextSpan(text: 'test'),
WidgetSpan(child: Container(width: 10, height: 10, color: Colors.blue)),
],
),
selection: const TextSelection.collapsed(offset: 3),
children: renderBoxes,
);
_applyParentData(renderBoxes, editable.text!);
layout(editable);
editable.hasFocus = true;
pumpFrame();
final Rect composingRect = editable.getRectForComposingRange(const TextRange(start: 4, end: 5))!;
expect(composingRect, const Rect.fromLTRB(40.0, -100.0, 54.0, -86.0));
}, skip: isBrowser); // https://github.com/flutter/flutter/issues/61021
test('can compute IntrinsicWidth for WidgetSpans', () {
// Regression test for https://github.com/flutter/flutter/issues/59316
const double screenWidth = 1000.0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment