From 7b250f911bd9e1d0502c41a082b7d31e97d1626b Mon Sep 17 00:00:00 2001 From: dab246 Date: Wed, 7 Jan 2026 15:21:12 +0700 Subject: [PATCH] TF-4233 Correctly set current label color on edit dialog open --- .../presentation/views/color/colors_map_widget.dart | 12 +++++++++++- .../handle_label_action_type_extension.dart | 7 +++++++ .../presentation/widgets/create_new_label_modal.dart | 1 + 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/core/lib/presentation/views/color/colors_map_widget.dart b/core/lib/presentation/views/color/colors_map_widget.dart index 68ac59784..a6f2e0a71 100644 --- a/core/lib/presentation/views/color/colors_map_widget.dart +++ b/core/lib/presentation/views/color/colors_map_widget.dart @@ -47,6 +47,9 @@ class _ColorsMapWidgetState extends State { Color(0xFF646580), ]; + static final Set _defaultColorValues = + _defaultColors.map((c) => c.toInt()).toSet(); + final ValueNotifier _selectedColor = ValueNotifier(null); List _colorList = []; @@ -128,7 +131,14 @@ class _ColorsMapWidgetState extends State { void _setUpColorList() { final custom = widget.customColor; - _colorList = custom != null ? [custom, ..._defaultColors] : _defaultColors; + final hasCustom = custom != null; + final isCustomInDefaults = + hasCustom && _defaultColorValues.contains(custom.toInt()); + + _colorList = (hasCustom && !isCustomInDefaults) + ? [custom, ..._defaultColors] + : _defaultColors; + _selectedColor.value = custom; } diff --git a/lib/features/labels/presentation/extensions/handle_label_action_type_extension.dart b/lib/features/labels/presentation/extensions/handle_label_action_type_extension.dart index 6adca9304..a9b733a13 100644 --- a/lib/features/labels/presentation/extensions/handle_label_action_type_extension.dart +++ b/lib/features/labels/presentation/extensions/handle_label_action_type_extension.dart @@ -33,6 +33,13 @@ extension HandleLabelActionTypeExtension on LabelController { required AccountId? accountId, required Label label, }) async { + if (accountId == null) { + consumeState( + Stream.value(Left(EditLabelFailure(NotFoundAccountIdException()))), + ); + return; + } + await DialogRouter().openDialogModal( child: CreateNewLabelModal( labels: labels, 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 a1600c9d2..b1768ea45 100644 --- a/lib/features/labels/presentation/widgets/create_new_label_modal.dart +++ b/lib/features/labels/presentation/widgets/create_new_label_modal.dart @@ -76,6 +76,7 @@ class _CreateNewLabelModalState extends State { _nameInputController.text = selectedLabel.safeDisplayName; _nameInputFocusNode.requestFocus(); _createLabelStateNotifier.value = true; + _labelSelectedColorNotifier.value = _selectedColor; } }); }