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

Fix : DOM nesting Warning in BreadCrumbs.tsx #9941

Closed
wants to merge 3 commits into from

Conversation

Rustix69
Copy link
Contributor

@Rustix69 Rustix69 commented Jan 14, 2025

Screenshots :
image

Reviewers : @rithviknishad @ohcnetwork/care-fe-code-reviewers

Summary by CodeRabbit

  • Improvements
    • Enhanced breadcrumb navigation with more streamlined rendering
    • Refined breadcrumb item display logic
    • Improved component-based structure for breadcrumbs
    • Updated back navigation button handling for better usability

@Rustix69 Rustix69 requested a review from a team as a code owner January 14, 2025 06:17
Copy link
Contributor

coderabbitai bot commented Jan 14, 2025

Walkthrough

The pull request modifies the Breadcrumbs.tsx component to address DOM nesting warnings and improve the component's structure. The changes involve removing the BreadcrumbSeparator component, updating the rendering of breadcrumb items to use BreadcrumbItem, and refactoring the navigation and dropdown menu logic. The implementation now provides a more streamlined and semantically correct approach to rendering breadcrumbs.

Changes

File Change Summary
src/components/Common/Breadcrumbs.tsx - Removed BreadcrumbSeparator component
- Replaced <li> with BreadcrumbItem
- Conditionally render Button or span for last item
- Refactored back navigation button handling
- Simplified showFullPath state management

Assessment against linked issues

Objective Addressed Explanation
Fix DOM Nesting Warning [#9936]

Possibly related PRs

Suggested labels

tested, reviewed

Suggested reviewers

  • rithviknishad
  • Jacobjeevan

Poem

🐰 Breadcrumbs dancing, neat and light,
No more warnings to give us fright!
Components aligned with grace so fine,
Rendering paths with a clearer design.
A rabbit's code, now clean and bright! 🍞✨


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 2a1fadd and c0fe827.

📒 Files selected for processing (1)
  • src/components/Common/Breadcrumbs.tsx (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/components/Common/Breadcrumbs.tsx

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.

Copy link

netlify bot commented Jan 14, 2025

Deploy Preview for care-ohc ready!

Name Link
🔨 Latest commit c0fe827
🔍 Latest deploy log https://app.netlify.com/sites/care-ohc/deploys/678603a5b39019000873f783
😎 Deploy Preview https://deploy-preview-9941--care-ohc.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@rithviknishad rithviknishad added invalid This doesn't seem right changes required and removed invalid This doesn't seem right changes required labels Jan 14, 2025
@rithviknishad
Copy link
Member

@Rustix69 I assume this is still work in progress?

@rithviknishad rithviknishad marked this pull request as draft January 14, 2025 06:20
@rithviknishad
Copy link
Member

mark it as draft until changes are completed

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: 2

🧹 Nitpick comments (1)
src/components/Common/Breadcrumbs.tsx (1)

73-90: Clean implementation of breadcrumb items!

Good improvements:

  • Proper semantic structure using BreadcrumbItem
  • Clean conditional rendering between interactive and non-interactive items
  • Consistent styling approach

Consider extracting the common Button props to reduce duplication:

const linkButtonProps = {
  asChild: true,
  variant: "link",
  className: "p-1 font-normal text-gray-800 hover:text-gray-700"
} as const;

// Usage
<Button {...linkButtonProps}>
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4a5fdff and 2a1fadd.

📒 Files selected for processing (1)
  • src/components/Common/Breadcrumbs.tsx (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: OSSAR-Scan
🔇 Additional comments (3)
src/components/Common/Breadcrumbs.tsx (3)

12-12: LGTM! Good use of structured UI components.

The addition of specialized UI components from the design system will help maintain consistent DOM hierarchy and styling.


98-114: Good improvements to the back button implementation!

The back button is now properly structured with:

  • Correct semantic hierarchy using BreadcrumbItem
  • Proper button type attribute
  • Clear styling classes
  • Improved click handler logic

Line range hint 1-142: Overall great improvements to the breadcrumbs component!

The changes successfully address the DOM nesting warnings by:

  1. Using proper semantic structure with BreadcrumbItem components
  2. Implementing clean conditional rendering
  3. Maintaining consistent styling and accessibility

A few items need attention:

  1. Implement the dropdown menu content
  2. Verify the intention behind showFullPath state
  3. Consider reducing Button props duplication

Comment on lines +128 to +130
<DropdownMenu>
{/* ... (dropdown menu content) ... */}
</DropdownMenu>
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Implementation needed for dropdown menu content.

The dropdown menu content is currently commented out. Please implement the menu content to ensure proper functionality.

@@ -57,7 +51,7 @@
}: BreadcrumbsProps) {
const { goBack } = useAppHistory();
const path = usePath();
const [showFullPath, setShowFullPath] = useState(false);
const [showFullPath] = useState(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Replace useState with a constant boolean value

The showFullPath state is never updated since its setter has been removed. Since it's initialized as false and never changes, replace useState(false) with a constant:

const showFullPath = false;

Or better yet, simplify the conditional rendering since showFullPath is always false:

{crumbs && crumbs.length > 1 && (
  <BreadcrumbItem>
    <DropdownMenu>
      {/* dropdown content */}
    </DropdownMenu>
  </BreadcrumbItem>
)}
🔗 Analysis chain

Verify if showFullPath state needs to be mutable.

The state setter for showFullPath has been removed, but the state is still used for conditional rendering. If this is intentional, consider using a constant instead of state.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any updates to showFullPath in the codebase
rg "setShowFullPath|showFullPath\s*=" --type typescript

Length of output: 92


Script:

#!/bin/bash
# Search for showFullPath usage and assignments
rg "showFullPath" -g "*.ts" -g "*.tsx" -A 2 -B 2

# Get the complete implementation of Breadcrumbs component
ast-grep --pattern 'const Breadcrumbs = $_: React.FC<$_> {
  $$$
}'

Length of output: 1131

@Rustix69
Copy link
Contributor Author

mark it as draft until changes are completed

@rithviknishad The Code is running quite good. I had pushed the PR you may check it.

The error was due to :

  • The renderCrumb function was returning an ( li ) element.
  • This function was being called within another ( li ) in the main render function.
  • The BreadcrumbItem component likely renders as an ( li ) creating nested ( li ) elements.

@Rustix69 Rustix69 marked this pull request as ready for review January 14, 2025 06:29
@rithviknishad
Copy link
Member

rithviknishad commented Jan 14, 2025

Closing as most of the changes doesn't make sense and is pretty much incomplete

@Rustix69 Rustix69 deleted the fix-dom-nesting-warning branch January 14, 2025 06:52
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.

Fix DOM Nesting Warning in BreadcrumbSeparator Component
2 participants