Skip to content
This repository has been archived by the owner on Jan 9, 2024. It is now read-only.

Commit

Permalink
feat: enter on keyboard to submit question
Browse files Browse the repository at this point in the history
  • Loading branch information
RuiMiguel committed Dec 7, 2023
1 parent cebcf77 commit 737a832
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class _QuestionTextFieldState extends State<QuestionInputTextField> {
color: VertexColors.flutterNavy,
),
autofillHints: null,
onSubmitted: (_) => widget.onActionPressed(),
decoration: InputDecoration(
filled: true,
fillColor: VertexColors.arctic,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,28 @@ void main() {
expect(text, equals('test'));
});

testWidgets('calls onActionPressed on enter key', (tester) async {
var called = false;
await tester.pumpApp(
Material(
child: QuestionInputTextField(
icon: SizedBox.shrink(),
hint: 'hint',
actionText: 'actionText',
onActionPressed: () {
called = true;
},
onTextUpdated: (_) {},
),
),
);

await tester.enterText(find.byType(TextField), '');
await tester.testTextInput.receiveAction(TextInputAction.done);

expect(called, equals(true));
});

group('when shouldDisplayClearTextButton is false', () {
testWidgets('calls onActionPressed clicking on PrimaryCTA',
(tester) async {
Expand Down

0 comments on commit 737a832

Please sign in to comment.