From 956d2dfd07dc0ceb55ab4e2ea45e0a2c1cb9e8e0 Mon Sep 17 00:00:00 2001 From: Richard Shiue <71320345+richardshiue@users.noreply.github.com> Date: Thu, 26 Dec 2024 12:18:17 +0800 Subject: [PATCH] fix(flutter_desktop): row detail checklist cell "create new" text field doesn't clear after clicking on create button (#7055) * fix: clear text controller when clicking on add button no matter what * test: add integration test --- .../desktop/database/database_row_page_test.dart | 10 ++++++++-- .../integration_test/shared/database_test_op.dart | 6 ++++++ .../desktop_row_detail_checklist_cell.dart | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/frontend/appflowy_flutter/integration_test/desktop/database/database_row_page_test.dart b/frontend/appflowy_flutter/integration_test/desktop/database/database_row_page_test.dart index 8874cefb1c..22f059d199 100644 --- a/frontend/appflowy_flutter/integration_test/desktop/database/database_row_page_test.dart +++ b/frontend/appflowy_flutter/integration_test/desktop/database/database_row_page_test.dart @@ -394,11 +394,16 @@ void main() { isChecked: false, ); tester.assertPhantomChecklistItemAtIndex(index: 1); + tester.assertPhantomChecklistItemContent(""); await tester.enterText(find.byType(PhantomChecklistItem), 'task 2'); await tester.pumpAndSettle(); - await tester.simulateKeyEvent(LogicalKeyboardKey.enter); - await tester.pumpAndSettle(const Duration(milliseconds: 500)); + await tester.hoverOnWidget( + find.byType(ChecklistRowDetailCell), + onHover: () async { + await tester.tapButton(find.byType(ChecklistItemControl)); + }, + ); tester.assertChecklistTaskInEditor( index: 1, @@ -406,6 +411,7 @@ void main() { isChecked: false, ); tester.assertPhantomChecklistItemAtIndex(index: 2); + tester.assertPhantomChecklistItemContent(""); await tester.simulateKeyEvent(LogicalKeyboardKey.escape); await tester.pumpAndSettle(); diff --git a/frontend/appflowy_flutter/integration_test/shared/database_test_op.dart b/frontend/appflowy_flutter/integration_test/shared/database_test_op.dart index ff7e33ebdf..676c96f042 100644 --- a/frontend/appflowy_flutter/integration_test/shared/database_test_op.dart +++ b/frontend/appflowy_flutter/integration_test/shared/database_test_op.dart @@ -567,6 +567,12 @@ extension AppFlowyDatabaseTest on WidgetTester { expect(phantom is PhantomChecklistItem, true); } + void assertPhantomChecklistItemContent(String content) { + final phantom = find.byType(PhantomChecklistItem); + final text = find.text(content); + expect(find.descendant(of: phantom, matching: text), findsOneWidget); + } + Future openFirstRowDetailPage() async { await hoverOnFirstRowOfGrid(); diff --git a/frontend/appflowy_flutter/lib/plugins/database/widgets/cell/desktop_row_detail/desktop_row_detail_checklist_cell.dart b/frontend/appflowy_flutter/lib/plugins/database/widgets/cell/desktop_row_detail/desktop_row_detail_checklist_cell.dart index d100a56860..d7e1d64fc3 100644 --- a/frontend/appflowy_flutter/lib/plugins/database/widgets/cell/desktop_row_detail/desktop_row_detail_checklist_cell.dart +++ b/frontend/appflowy_flutter/lib/plugins/database/widgets/cell/desktop_row_detail/desktop_row_detail_checklist_cell.dart @@ -89,7 +89,6 @@ class _ChecklistRowDetailCellState extends State { onTap: () { final bloc = context.read(); if (bloc.state.phantomIndex == null) { - phantomTextController.clear(); bloc.add( ChecklistCellEvent.updatePhantomIndex( bloc.state.showIncompleteOnly @@ -107,6 +106,7 @@ class _ChecklistRowDetailCellState extends State { ), ); } + phantomTextController.clear(); }, ), ],