fix: use toString() for label color selection comparison#1378
fix: use toString() for label color selection comparison#1378MrgSub merged 1 commit intoMail-0:stagingfrom
Conversation
WalkthroughThe changes update the label creation and editing flow in the mail application's settings. The "Create Label" button no longer resets the editing state on click, delegating this responsibility to the dialog's open state handler. Additionally, the label dialog's color selection logic and default values are refined for consistency and improved UI feedback. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant SettingsPage
participant LabelDialog
User->>SettingsPage: Click "Create Label" button
SettingsPage->>LabelDialog: Open dialog (no immediate state reset)
LabelDialog->>SettingsPage: onOpenChange (handle editingLabel reset on close)
Poem
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
apps/mail/components/labels/label-dialog.tsx (1)
132-134: Main color comparison fix looks good, but add safer null checking.The toString() method correctly fixes the object reference comparison issue mentioned in the PR objectives. However, consider adding safer null checking to prevent potential runtime errors.
Consider this safer approach:
- formColor?.backgroundColor.toString() === color.backgroundColor && - formColor.textColor.toString() === color.textColor + formColor?.backgroundColor?.toString() === color.backgroundColor && + formColor?.textColor?.toString() === color.textColor
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
apps/mail/app/(routes)/settings/labels/page.tsx(1 hunks)apps/mail/components/labels/label-dialog.tsx(2 hunks)
🔇 Additional comments (2)
apps/mail/components/labels/label-dialog.tsx (1)
134-134: Good UI enhancement with the ring-offset styling.The addition of
ring-offset-1improves the visual feedback for selected color buttons.apps/mail/app/(routes)/settings/labels/page.tsx (1)
89-89: Good simplification of state management.Removing the onClick handler that immediately reset
editingLabelto null is a good change. The state reset is now properly handled by theonOpenChangecallback when the dialog closes, which is more appropriate and eliminates redundant state manipulation.
Description
Issue was caused due to the direct comparison between form's color and the mapped color labels .The toString() method ensures you're comparing the actual string values rather than object references.
Type of Change
Please delete options that are not relevant.
Areas Affected
Please check all that apply:
Testing Done
Describe the tests you've done:
Security Considerations
For changes involving data or authentication:
Checklist
Screenshots/Recordings
Production:

Dev (After fix):

By submitting this pull request, I confirm that my contribution is made under the terms of the project's license.
Summary by CodeRabbit