From fdae0578378c93791207ed5a70a5bd9a70446e1c Mon Sep 17 00:00:00 2001 From: dab246 Date: Wed, 25 Mar 2026 15:53:44 +0700 Subject: [PATCH] TF-4370 Fix selector/key wiring: modal instantiation does not pass the key the test expects --- .../scenarios/labels/create_new_a_tag_scenario.dart | 5 +++-- lib/features/labels/presentation/label_controller.dart | 1 + .../labels/presentation/widgets/create_new_label_modal.dart | 5 ++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/integration_test/scenarios/labels/create_new_a_tag_scenario.dart b/integration_test/scenarios/labels/create_new_a_tag_scenario.dart index 35a4f8918..903bbabd4 100644 --- a/integration_test/scenarios/labels/create_new_a_tag_scenario.dart +++ b/integration_test/scenarios/labels/create_new_a_tag_scenario.dart @@ -21,8 +21,9 @@ class CreateNewATagScenario extends BaseTestScenario { await $.pumpAndTrySettle(); await _expectCreateNewLabelModalVisible(); - const newLabelName = 'Create new tag 1'; - const newLabelDescription = 'Description tag 1'; + final uniqueSuffix = DateTime.now().microsecondsSinceEpoch; + final newLabelName = 'Create new tag $uniqueSuffix'; + final newLabelDescription = 'Description tag $uniqueSuffix'; await createLabelModalRobot.enterNewLabelName(newLabelName); await createLabelModalRobot.enterNewLabelDescription(newLabelDescription); await createLabelModalRobot.tapPositiveActionButton(LabelActionType.create); diff --git a/lib/features/labels/presentation/label_controller.dart b/lib/features/labels/presentation/label_controller.dart index a009c3467..629b390c4 100644 --- a/lib/features/labels/presentation/label_controller.dart +++ b/lib/features/labels/presentation/label_controller.dart @@ -148,6 +148,7 @@ class LabelController extends BaseController with LabelContextMenuMixin { await DialogRouter().openDialogModal( child: CreateNewLabelModal( + key: const Key('create_new_label_modal'), labels: labels, onLabelActionCallback: (label) => _createNewLabel(accountId, label), ), diff --git a/lib/features/labels/presentation/widgets/create_new_label_modal.dart b/lib/features/labels/presentation/widgets/create_new_label_modal.dart index ce1947239..4f232cf7a 100644 --- a/lib/features/labels/presentation/widgets/create_new_label_modal.dart +++ b/lib/features/labels/presentation/widgets/create_new_label_modal.dart @@ -363,6 +363,7 @@ class _CreateNewLabelModalState extends State { void _clearInputFocus() { _nameInputFocusNode.unfocus(); + _descriptionInputFocusNode.unfocus(); } void _onCreateNewLabel() { @@ -373,7 +374,9 @@ class _CreateNewLabelModalState extends State { color: _selectedColor != null ? HexColor(_selectedColor!.toHexTriplet()) : null, - description: _descriptionInputController.text, + description: _descriptionInputController.text.trim().isEmpty + ? null + : _descriptionInputController.text.trim(), ); widget.onLabelActionCallback(newLabel);