Chat composer: a newline at the line limit scrolls to the new line
At the field's line limit, a newline at the end left the caret on an empty line the field only scrolled to after the next character. The field now scrolls to the end right after such an edit.
This commit is contained in:
@@ -40,4 +40,31 @@ void main() {
|
||||
expect(phone, greaterThan(6));
|
||||
});
|
||||
}
|
||||
|
||||
for (final cupertino in [false, true]) {
|
||||
final host = cupertino ? 'Cupertino' : 'Material';
|
||||
testWidgets('$host: a newline at the line limit scrolls to the new '
|
||||
'empty line at once', (tester) async {
|
||||
final gateway = ComposerBarGateway()..page = fixtureTurn();
|
||||
addTearDown(gateway.close);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
tester.view.physicalSize = const Size(900, 1000);
|
||||
addTearDown(tester.view.reset);
|
||||
await tester.pumpWidget(composerThread(gateway, cupertino: cupertino));
|
||||
await tester.pump();
|
||||
final field = find.byKey(const Key('chat-composer-field'));
|
||||
// Past the 12-line limit, then a newline at the end: no character
|
||||
// typed on the new line yet.
|
||||
final text = List.generate(14, (i) => 'line $i').join('\n');
|
||||
await tester.enterText(field, '$text\n');
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
final scrollable = tester.state<ScrollableState>(
|
||||
find.descendant(of: field, matching: find.byType(Scrollable)).first,
|
||||
);
|
||||
final position = scrollable.position;
|
||||
expect(position.maxScrollExtent, greaterThan(0));
|
||||
expect(position.pixels, moreOrLessEquals(position.maxScrollExtent));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user