Skip to content

Conversation

@mulikruchi07
Copy link
Contributor

Description

This PR introduces validation and displays clear inline error messages:

  • "Please enter a tag" when the input is empty
  • "Tag already exists" when the user tries to add a duplicate tag
  • Support comma-separated tag input (e.g. "t1, t2")
  • Ensure tags are saved correctly when adding/editing tasks

The dialog now remains open until a valid tag is submitted.

Fixes #518

Screenshots

after#518 1
after#518 2

TAG.mp4

Checklist

  • Tests have been added or updated to cover the changes
  • Documentation has been updated to reflect the changes
  • Code follows the established coding style guidelines
  • All tests are passing

Copilot AI review requested due to automatic review settings February 9, 2026 17:58
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds inline validation to the task tag editor dialog to prevent empty/duplicate tags and allow comma-separated input, aligning the UX with issue #518.

Changes:

  • Added comma-separated parsing and multi-tag add support (_parseTags, _addTags).
  • Added inline form validation for empty input, spaces, and duplicates.
  • Updated tag selection chips to use the new multi-add path.
Comments suppressed due to low confidence (1)

lib/app/modules/detailRoute/views/tags_widget.dart:293

  • After moving validation into the TextFormField.validator, the try { ... } on FormatException block no longer appears to protect any code that can throw (and will likely leave validate.dart / loggy imports unused). Consider removing the try/catch here and cleaning up any now-unused imports to keep flutter analyze clean.
                    if (formKey.currentState!.validate()) {
                      try {
                        final tags = _parseTags(controller.text);
                        _addTags(tags);
                        Get.back();
                      } on FormatException catch (e, trace) {
                        logError(e, trace);
                      }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 287 to 291
try {
validateTaskTags(controller.text);
_addTag(controller.text);
// Navigator.of(context).pop();
final tags = _parseTags(controller.text);
_addTags(tags);
Get.back();
} on FormatException catch (e, trace) {
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change introduces new validation behavior (empty input, duplicates, comma-separated submission, and keeping the dialog open on invalid submit), but there are no widget tests covering it. Please add a widget test for TagsRoute that asserts inline errors are shown and that the dialog only closes when a valid tag (or tag list) is submitted.

Copilot uses AI. Check for mistakes.
draftTags ??= ListBuilder<String>();

for (final tag in tags) {
if (!draftTags!.build().contains(tag)) {
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In _addTags, calling draftTags!.build() inside the loop allocates a new immutable list on every iteration. Use draftTags!.contains(tag) (ListBuilder supports contains) or build once before the loop / keep a Set for membership checks to avoid repeated allocations and quadratic behavior as tags grow.

Suggested change
if (!draftTags!.build().contains(tag)) {
if (!draftTags!.contains(tag)) {

Copilot uses AI. Check for mistakes.
Comment on lines 246 to 261
validator: (value) {
if (value != null) {
if (value.isNotEmpty && value.contains(" ")) {
final tags = _parseTags(value ?? '');

if (tags.isEmpty) {
return "Please enter a tag";
}

for (final tag in tags) {
if (tag.contains(' ')) {
return "Tags cannot contain spaces";
}

if (draftTags?.build().contains(tag) ?? false) {
return "Tag already exists";
}
}
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The validator introduces hard-coded English error strings ("Please enter a tag", "Tags cannot contain spaces", "Tag already exists"), which bypasses the app’s localization approach via SentenceManager (e.g., sentences.tagAlreadyExists, sentences.tagShouldNotContainSpaces). Please switch these to localized SentenceManager(...).sentences entries, and add a new sentences key for the empty-input message so it’s translated consistently.

Copilot uses AI. Check for mistakes.
return "Tags cannot contain spaces";
}

if (draftTags?.build().contains(tag) ?? false) {
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

draftTags?.build().contains(tag) in the validator has the same repeated-allocation issue as in _addTags. Prefer draftTags?.contains(tag) (or build once outside the loop) to avoid creating a new BuiltList during every validation pass (which can be triggered frequently while typing).

Suggested change
if (draftTags?.build().contains(tag) ?? false) {
if (draftTags?.contains(tag) ?? false) {

Copilot uses AI. Check for mistakes.
@Pavel401
Copy link
Member

Screen.Recording.2026-02-10.at.11.20.49.AM.mov

It's still there

@SGI-CAPP-AT2
Copy link
Collaborator

Screen.Recording.2026-02-10.at.11.20.49.AM.mov
It's still there

@mulikruchi07 , Also check it with the Taskchampion type of Server
You can try changing server from profile page

Tag editor is not used there so you may need to implement it.

@SGI-CAPP-AT2
Copy link
Collaborator

I was thinking to replace this tags editor with bottom sheet with only tag editor which is in add task bottom sheet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Duplicate or Empty Tags Allowed Without Showing Inline Validation Message

3 participants