Skip to content

fix: Improve label colors validations - #183

Merged
dkorecko merged 2 commits into
mainfrom
fix/label-colors-validation
Jul 1, 2026
Merged

dkorecko merged 2 commits into
mainfrom
fix/label-colors-validation

Conversation

@dkorecko

@dkorecko dkorecko commented Jul 1, 2026 •

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features

    • Label colors now always have default values, so labels open with consistent text and background colors.
    • Add/Edit label dialogs now show and save color selections more reliably.
  • Bug Fixes

    • Improved label color handling to prevent missing or null color values.
    • Validation in the edit dialog now tracks the label being edited more accurately.

@coderabbitai

coderabbitai Bot commented Jul 1, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

@dkorecko, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 12 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 5f099244-8813-47df-ad1a-ea56503793f1

📥 Commits

Reviewing files that changed from the base of the PR and between 6e54436 and 5199bd2.

📒 Files selected for processing (4)
  • Ticky.Base/Models/LabelModel.cs
  • Ticky.Internal/Helpers/ColorHelper.cs
  • Ticky.Web/Components/Dialogs/AddLabelModal.razor
  • Ticky.Web/Components/Dialogs/EditLabelModal.razor
📝 Walkthrough

Walkthrough

LabelModel's TextColor and BackgroundColor properties change from nullable Color? to non-nullable Color with default values and simplified Required attributes. AddLabelModal and EditLabelModal are updated to bind color inputs directly and persist colors without nullable/null-forgiving handling; EditLabelModal's EditContext now uses _labelModel.

Changes

Label Color Non-Nullability

Layer / File(s) Summary
LabelModel color contract
Ticky.Base/Models/LabelModel.cs
TextColor and BackgroundColor become non-nullable Color with default values (White, Red) and [Required] attributes.
Add Label modal color handling
Ticky.Web/Components/Dialogs/AddLabelModal.razor
Color inputs bind via ColorTranslator.ToHtml(...) directly, preview label initializes from _labelModel, and AddLabel assigns colors from _labelModel without null-forgiving access.
Edit Label modal color handling and validation
Ticky.Web/Components/Dialogs/EditLabelModal.razor
Color inputs bind via ColorTranslator.ToHtml(...) directly, EditContext is built from _labelModel instead of _board, and EditLabel assigns colors from _labelModel directly.

Related PRs: None identified.

Suggested labels: enhancement, bug

Suggested reviewers: dkorecko

Poem:
A rabbit hopped through colors bright,
No longer null, they hold the light.
White for text, red for the tag,
No more !.Value to drag.
Labels bloom in every hue,
Ticky's board is fresh and true! 🐇🎨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the main change: label color validation and handling were improved.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/label-colors-validation

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@dkorecko dkorecko linked an issue Jul 1, 2026 that may be closed by this pull request

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Ticky.Base/Models/LabelModel.cs`:
- Around line 9-15: The [Required] attributes on LabelModel.TextColor and
LabelModel.BackgroundColor are ineffective because these Color structs can’t be
null, so replace them with validation that explicitly rejects invalid values
such as Color.Empty or add a custom validator on LabelModel to enforce allowed
colors. Keep the Display metadata if needed, but remove the misleading Required
annotations from these properties.

In `@Ticky.Web/Components/Dialogs/AddLabelModal.razor`:
- Around line 18-27: The Required attributes on LabelModel.TextColor and
LabelModel.BackgroundColor are ineffective because these non-nullable Color
properties are always initialized, so the ValidationMessage fields in
AddLabelModal and the matching label modal will never show. Update LabelModel to
use real validation for unset/default colors, such as IValidatableObject or a
custom validation attribute that rejects Color.Empty/default, and keep the modal
bindings and ValidationMessage references pointing at the same TextColor and
BackgroundColor members.
- Around line 19-25: The color inputs in AddLabelModal and EditLabelModal are
binding values through ColorTranslator.ToHtml, which can output named colors
instead of the hex format required by input type="color". Update the value
binding in the color picker fields and any related helper logic so the displayed
value is always serialized as `#rrggbb`, using the existing
OnTextColorUpdated/OnBackgroundColorUpdated handlers and LabelModel color
properties as the reference points.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 844a1563-8763-4c18-9baa-2a03a5062f15

📥 Commits

Reviewing files that changed from the base of the PR and between 35724d1 and 6e54436.

📒 Files selected for processing (3)
  • Ticky.Base/Models/LabelModel.cs
  • Ticky.Web/Components/Dialogs/AddLabelModal.razor
  • Ticky.Web/Components/Dialogs/EditLabelModal.razor

Comment thread Ticky.Base/Models/LabelModel.cs Outdated
Comment on lines +9 to +15
[Required]
[Display(Name = "Text color")]
public Color? TextColor { get; set; }
public Color TextColor { get; set; } = Color.White;

[Required(AllowEmptyStrings = false)]
[Required]
[Display(Name = "Background color")]
public Color? BackgroundColor { get; set; }
public Color BackgroundColor { get; set; } = Color.Red;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

[Required] does nothing on these Color properties.
TextColor and BackgroundColor are non-nullable structs, so [Required] will never fail here and gives a false sense of validation. If the goal is to reject unset/invalid colors, use a check for Color.Empty or a custom validator instead.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Ticky.Base/Models/LabelModel.cs` around lines 9 - 15, The [Required]
attributes on LabelModel.TextColor and LabelModel.BackgroundColor are
ineffective because these Color structs can’t be null, so replace them with
validation that explicitly rejects invalid values such as Color.Empty or add a
custom validator on LabelModel to enforce allowed colors. Keep the Display
metadata if needed, but remove the misleading Required annotations from these
properties.

Comment on lines 18 to 27
<Name For="() => _labelModel.TextColor" />
<input type="color" value="@(_labelModel.TextColor.HasValue ? ColorTranslator.ToHtml(_labelModel.TextColor.Value) : string.Empty)" @onchange="OnTextColorUpdated" />
<input type="color" value="@ColorTranslator.ToHtml(_labelModel.TextColor)" @onchange="OnTextColorUpdated" />
<ValidationMessage For="() => _labelModel.TextColor" />
</div>

<div class="form-group">
<Name For="() => _labelModel.BackgroundColor" />
<input type="color" value="@(_labelModel.BackgroundColor.HasValue ? ColorTranslator.ToHtml(_labelModel.BackgroundColor.Value) : string.Empty)" @onchange="OnBackgroundColorUpdated" />
<input type="color" value="@ColorTranslator.ToHtml(_labelModel.BackgroundColor)" @onchange="OnBackgroundColorUpdated" />
<ValidationMessage For="() => _labelModel.BackgroundColor" />
</div>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Locate relevant files and symbols.
git ls-files | rg 'Ticky\.Web/Components/Dialogs/(AddLabelModal|EditLabelModal)\.razor|LabelModel|Models|ViewModels'
rg -n --hidden --glob '!**/bin/**' --glob '!**/obj/**' \
  'TextColor|BackgroundColor|IValidatableObject|Color\.Empty|\[Required\]' \
  Ticky.Web 2>/dev/null || true

# Show file sizes before reading.
for f in \
  Ticky.Web/Components/Dialogs/AddLabelModal.razor \
  Ticky.Web/Components/Dialogs/EditLabelModal.razor \
  Ticky.Web/Models/LabelModel.cs
do
  if [ -f "$f" ]; then
    wc -l "$f"
  fi
done

# Read the relevant files if present.
for f in \
  Ticky.Web/Components/Dialogs/AddLabelModal.razor \
  Ticky.Web/Components/Dialogs/EditLabelModal.razor \
  Ticky.Web/Models/LabelModel.cs
do
  if [ -f "$f" ]; then
    echo "===== $f ====="
    cat -n "$f"
  fi
done

Repository: dkorecko/Ticky

Length of output: 16349


🏁 Script executed:

#!/bin/bash
set -euo pipefail

f=Ticky.Base/Models/LabelModel.cs
if [ -f "$f" ]; then
  wc -l "$f"
  cat -n "$f"
fi

# Look for any validation hooks that might make Color validation effective.
rg -n --hidden --glob '!**/bin/**' --glob '!**/obj/**' \
  'class LabelModel|IValidatableObject|Validate\(|Color\.Empty|BackgroundColor|TextColor|RequiredAttribute|Display\(' \
  Ticky.Base Ticky.Web 2>/dev/null || true

Repository: dkorecko/Ticky

Length of output: 13218


[Required] on LabelModel.TextColor / BackgroundColor is inert.

Color is non-nullable and already initialized, so these attributes can never fail; the color ValidationMessages in both label modals won’t ever surface. If the goal is to reject default/unset colors, use custom validation in LabelModel (for example IValidatableObject or a custom attribute that rejects Color.Empty/default).

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Ticky.Web/Components/Dialogs/AddLabelModal.razor` around lines 18 - 27, The
Required attributes on LabelModel.TextColor and LabelModel.BackgroundColor are
ineffective because these non-nullable Color properties are always initialized,
so the ValidationMessage fields in AddLabelModal and the matching label modal
will never show. Update LabelModel to use real validation for unset/default
colors, such as IValidatableObject or a custom validation attribute that rejects
Color.Empty/default, and keep the modal bindings and ValidationMessage
references pointing at the same TextColor and BackgroundColor members.

Comment thread Ticky.Web/Components/Dialogs/AddLabelModal.razor Outdated
@dkorecko
dkorecko merged commit 3fd4efc into main Jul 1, 2026
6 checks passed
@dkorecko
dkorecko deleted the fix/label-colors-validation branch July 1, 2026 17:33
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.

[Bug] Custom Label "The Text color field is required."

2 participants