TF-4233 Correctly set current label color on edit dialog open

This commit is contained in:
dab246
2026-01-07 15:21:12 +07:00
committed by Dat H. Pham
parent ac33424c30
commit 7b250f911b
3 changed files with 19 additions and 1 deletions
@@ -47,6 +47,9 @@ class _ColorsMapWidgetState extends State<ColorsMapWidget> {
Color(0xFF646580),
];
static final Set<int> _defaultColorValues =
_defaultColors.map((c) => c.toInt()).toSet();
final ValueNotifier<Color?> _selectedColor = ValueNotifier(null);
List<Color> _colorList = <Color>[];
@@ -128,7 +131,14 @@ class _ColorsMapWidgetState extends State<ColorsMapWidget> {
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;
}
@@ -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,
@@ -76,6 +76,7 @@ class _CreateNewLabelModalState extends State<CreateNewLabelModal> {
_nameInputController.text = selectedLabel.safeDisplayName;
_nameInputFocusNode.requestFocus();
_createLabelStateNotifier.value = true;
_labelSelectedColorNotifier.value = _selectedColor;
}
});
}