Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WEB-1412]fix: split labels in kanban board #6253

Open
wants to merge 1 commit into
base: preview
Choose a base branch
from

Conversation

mathalav55
Copy link
Collaborator

@mathalav55 mathalav55 commented Dec 21, 2024

Description

  • Fixed the issue where labels in a Kanban card were constrained to a single line, preventing them from wrapping into multiple lines. The changes ensure that labels can now wrap as needed.
  • Refactored the component structure to provide each label or label group with its own dropdown.
  • Adjusted the logic to handle multiple dropdowns, ensuring that interactions with one dropdown do not affect others.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Improvement (change that would cause existing functionality to not work as expected)
  • Code refactoring
  • Performance improvements
  • Documentation update

Screenshots and Media (if applicable)

Screenshot 2024-12-21 at 11 59 49 AM

Test Scenarios

Tested the functionality of isolated dropdowns to ensure they operate independently and correctly.

References

WEB-1412

Summary by CodeRabbit

  • New Features

    • Introduced a new LabelDropdown component for managing issue labels.
    • Expanded exports to include functionalities from the label-dropdown module.
  • Improvements

    • Enhanced clarity in the IssueProperties component with explicit checks for updates.
    • Simplified rendering of the IssuePropertyLabels component by removing unnecessary wrappers.
  • Bug Fixes

    • Adjusted dropdown handling logic in the IssuePropertyLabels component for better user experience.
  • Chores

    • Cleaned up unused imports in various components to streamline code.

@mathalav55 mathalav55 added 🐛bug Something isn't working 🌟enhancement New feature or request labels Dec 21, 2024
@mathalav55 mathalav55 added this to the v0.24.2 milestone Dec 21, 2024
@mathalav55 mathalav55 self-assigned this Dec 21, 2024
Copy link
Contributor

coderabbitai bot commented Dec 21, 2024

Walkthrough

The pull request introduces several modifications to issue property management components, primarily focusing on label handling and dropdown interactions. A new LabelDropdown component is added to provide a more streamlined and user-friendly approach to label selection. The changes simplify the rendering of label-related components across multiple files, removing unnecessary <div> wrappers and updating the interaction model for label management. The modifications enhance code readability and component structure while maintaining the existing functionality of issue property handling.

Changes

File Change Summary
web/core/components/issues/issue-layouts/properties/all-properties.tsx Refined conditional checks for updateIssue function, removed <div> wrapper around IssuePropertyLabels
web/core/components/issues/issue-layouts/properties/index.ts Added export for label-dropdown module
web/core/components/issues/issue-layouts/properties/label-dropdown.tsx New component introducing LabelDropdown with comprehensive label selection functionality
web/core/components/issues/issue-layouts/properties/labels.tsx Updated IIssuePropertyLabels interface, simplified dropdown interactions, integrated new LabelDropdown component
web/core/components/issues/issue-layouts/spreadsheet/columns/label-column.tsx Added fullHeight prop to IssuePropertyLabels
web/core/components/issues/workspace-draft/draft-issue-properties.tsx Removed <div> wrapper around IssuePropertyLabels

Sequence Diagram

sequenceDiagram
    participant User
    participant LabelDropdown
    participant ProjectLabels
    
    User->>LabelDropdown: Open dropdown
    LabelDropdown->>ProjectLabels: Fetch available labels
    ProjectLabels-->>LabelDropdown: Return labels
    LabelDropdown->>User: Display searchable label options
    User->>LabelDropdown: Select/Search label
    LabelDropdown->>User: Update selected labels
Loading

Possibly related PRs

Suggested labels

🎨UI / UX, 🌐frontend

Suggested reviewers

  • SatishGandham
  • rahulramesha

Poem

🐰 Hop, hop, labels dance with glee,
Dropdowns now smooth as can be!
No more div wraps, just pure delight,
Coding rabbits make interfaces bright!
Select with ease, no extra fuss,
Our label magic is simply plus! 🏷️


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@mathalav55 mathalav55 marked this pull request as draft December 21, 2024 07:14
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
web/core/components/issues/issue-layouts/properties/labels.tsx (1)

170-197: Handling empty label scenario cleanly.
When there are no labels, relying on the 'LabelDropdown' with a placeholder text improves consistency and user experience.

Consider reusing the same approach (showing “x labels”) even when the count is 0 to reduce visual differences, especially if the user flow might benefit from uniform styling.

web/core/components/issues/issue-layouts/properties/label-dropdown.tsx (2)

103-114: Popper configuration with 'preventOverflow'.
This ensures the dropdown remains visible. Check for edge cases on extremely small viewports, though the default options appear sensible.


194-198: Propagation prevention inside the wrapper

.
This pattern ensures the parent doesn't inadvertently capture the events.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2384978 and 52b2e0a.

📒 Files selected for processing (6)
  • web/core/components/issues/issue-layouts/properties/all-properties.tsx (8 hunks)
  • web/core/components/issues/issue-layouts/properties/index.ts (1 hunks)
  • web/core/components/issues/issue-layouts/properties/label-dropdown.tsx (1 hunks)
  • web/core/components/issues/issue-layouts/properties/labels.tsx (3 hunks)
  • web/core/components/issues/issue-layouts/spreadsheet/columns/label-column.tsx (1 hunks)
  • web/core/components/issues/workspace-draft/draft-issue-properties.tsx (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • web/core/components/issues/issue-layouts/properties/index.ts
  • web/core/components/issues/workspace-draft/draft-issue-properties.tsx
🔇 Additional comments (21)
web/core/components/issues/issue-layouts/properties/labels.tsx (5)

6-16: Imports appear correct.
These newly added imports for "Tags", "Tooltip", "useLabel", "usePlatformOS", and "LabelDropdown" look consistent with the usage within this file.


36-36: New 'fullHeight' prop introduced in interface.
This prop broadens layout control. It's well-defined and optional. Ensure that other consuming components handle or ignore it as intended.


55-55: Default assignment to 'fullHeight'.
Assigning a default value of false aligns with a conservative approach that doesn't alter current layouts for existing users.


86-133: Refactored block to utilize ‘LabelDropdown’ for each label.
This significantly simplifies the code for rendering multiple labels. The separation of concerns into a dedicated dropdown is clearer. Good work!


134-168: Single 'LabelDropdown' usage when label count exceeds maxRender.
This fallback is a neat solution for handling numerous labels. The logic is straightforward and effectively reuses the same dropdown.

web/core/components/issues/issue-layouts/properties/label-dropdown.tsx (12)

16-33: Interface definition for 'LabelDropdown'.
Nice job defining a dedicated interface for clarity. The addition of “fullHeight” aligns well with the prop usage in “labels.tsx.”


59-64: Dropdown open state & query management.
Managing these as local states is a clean approach that isolates dropdown-specific concerns from parents.


73-80: Fetching labels and label creation.
Centralizing logic in 'useLabel' keeps the dropdown lean. Good approach.


84-99: Mapping project labels to ‘options’.
This pattern is straightforward. The “line-clamp” usage to handle potential overflow is a user-friendly touch.


115-119: 'onOpen' function fetches labels if not already available.
Great to see lazy loading of data only when needed.


120-125: ‘toggleDropdown’ logic.
Invoking 'onClose' when closing the dropdown fosters a cohesive two-way binding with the parent. Good use of callbacks.


133-141: 'handleAddLabel' allows dynamic label creation.
Please confirm that you have server-side validations for label conflicts or naming constraints to ensure consistent data integrity.


142-153: Search input key handling.
Preventing default events on “Enter” helps avoid undesired form submissions. Straightforward approach.


155-162: 'handleOnClick' preventing default event propagation.
This is best practice for handling nested clickable elements.


170-171: Dropdown button composition & popper referencing.
Using references from setReferenceElement and setPopperElement is a neat approach for flexible positioning.

Also applies to: 172-192


200-293: Conditional rendering of <Combobox.Options>
Code is well-structured, handling loading states, placeholders, and creation of new labels. The approach is consistent with Headless UI patterns.


35-54: Component signature and prop destructuring.
The destructuring approach is concise. Ensure that default values are thoroughly tested, especially when 'projectId' is null to avoid unexpected states.

Would you like to confirm usage patterns across the codebase with a quick search for “<LabelDropdown ” to ensure null projectId is handled gracefully?

✅ Verification successful

Let me check how projectId is used within the component to ensure proper null handling.


Null projectId handling is properly implemented.
The component has appropriate null checks for projectId in critical operations. The handleAddLabel function checks for projectId before proceeding (line 134), and the onOpen callback only fetches labels when both workspaceSlug and projectId are present (line 116). The component gracefully handles cases where projectId is null by using defaultOptions as a fallback (lines 81-82).

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
rg -A 5 $'<LabelDropdown'

Length of output: 1806


Script:

#!/bin/bash
# Check the implementation of LabelDropdown to see how projectId is used
ast-grep --pattern 'const LabelDropdown = $_' -A 50 web/core/components/issues/issue-layouts/properties/label-dropdown.tsx

Length of output: 28624

web/core/components/issues/issue-layouts/spreadsheet/columns/label-column.tsx (1)

40-40: New ‘fullHeight’ prop usage in 'IssuePropertyLabels'.
This usage matches the interface changes in “labels.tsx,” expanding layout flexibility in the spreadsheet view.

web/core/components/issues/issue-layouts/properties/all-properties.tsx (3)

99-99: Explicit null check on 'updateIssue'.
Switching from a shorthand AND to an if-statement clarifies code intent.


114-114: Repeated checks before calling 'updateIssue'.
This pattern improves safety by ensuring the function exists before invoking it. The explicit approach is more readable and robust.

Also applies to: 129-129, 144-144, 198-198, 215-215, 232-232


309-317: Removing the extra

wrapper around 'IssuePropertyLabels'.
Simplifying the DOM structure is a nice improvement. No issues spotted.

@mathalav55 mathalav55 marked this pull request as ready for review December 21, 2024 07:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛bug Something isn't working 🌟enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant