Fix breadcrumb overflow for long chapter names on small screens#2972
Fix breadcrumb overflow for long chapter names on small screens#2972kasya merged 1 commit intoOWASP:mainfrom
Conversation
WalkthroughThe PR wraps breadcrumb titles with the TruncatedText component to enable text truncation on smaller screens. Changes include adding TruncatedText imports and wrappers in BreadCrumbs and BreadCrumbsWrapper components, adding a min-w-0 class for proper truncation behavior, and updating the test selector to reference the parent element. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Possibly related PRs
Suggested labels
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
|
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
frontend/src/components/BreadCrumbs.tsx (1)
20-20: Missingmin-w-0breaks truncation behavior.The
baseclass is missingmin-w-0, which was added inBreadCrumbsWrapper.tsx(line 24). Without this, flexbox items cannot shrink below their content width, preventing the truncation from working properly.🔎 Proposed fix
itemClasses={{ - base: 'transition-colors duration-200', + base: 'transition-colors duration-200 min-w-0', item: 'text-sm font-medium', separator: 'flex items-center', }}
🧹 Nitpick comments (1)
frontend/src/components/BreadCrumbs.tsx (1)
5-5: TruncatedText usage is correct, but verify consistency.The TruncatedText implementation looks good and matches the pattern in
BreadCrumbsWrapper.tsx. However, note these minor inconsistencies between the two components:
- Line 29: Missing
isDisabled={isLast}prop (present in BreadCrumbsWrapper line 33)- Line 3: Imports
FaChevronRightfrom'react-icons/fa'while BreadCrumbsWrapper uses'react-icons/fa6'- Line 32: Uses
text-gray-600 dark:text-gray-300while BreadCrumbsWrapper usestext-gray-800 dark:text-gray-100If these differences are intentional (e.g., different design requirements for the two components), please disregard. Otherwise, consider aligning them for consistency.
Also applies to: 35-48
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
frontend/__tests__/unit/components/BreadCrumbs.test.tsx(1 hunks)frontend/src/components/BreadCrumbs.tsx(2 hunks)frontend/src/components/BreadCrumbsWrapper.tsx(3 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-07-13T07:31:06.511Z
Learnt from: Rajgupta36
Repo: OWASP/Nest PR: 1717
File: frontend/src/components/ModuleCard.tsx:53-55
Timestamp: 2025-07-13T07:31:06.511Z
Learning: In Next.js 13+ app router, useRouter from 'next/navigation' does not provide asPath or query properties. Use useParams to extract route parameters and usePathname to get the current pathname instead.
Applied to files:
frontend/src/components/BreadCrumbsWrapper.tsx
🧬 Code graph analysis (2)
frontend/src/components/BreadCrumbs.tsx (1)
frontend/src/components/TruncatedText.tsx (1)
TruncatedText(3-45)
frontend/src/components/BreadCrumbsWrapper.tsx (1)
frontend/src/components/TruncatedText.tsx (1)
TruncatedText(3-45)
🔇 Additional comments (3)
frontend/src/components/BreadCrumbsWrapper.tsx (2)
8-8: LGTM! Truncation implementation is correct.The TruncatedText component is properly imported and applied to both the last item and non-last items with responsive max-width constraints. This will effectively prevent overflow on small screens while allowing full display on larger screens (768px+).
Also applies to: 36-49
24-24: Essential:min-w-0enables flexbox truncation.The addition of
min-w-0to the base item class is critical. In flexbox layouts, items havemin-width: autoby default, preventing them from shrinking below their content size. Settingmin-w-0allows the items to shrink, which is necessary for the truncation to work properly.frontend/__tests__/unit/components/BreadCrumbs.test.tsx (1)
56-57: LGTM! Test correctly adapted to new DOM structure.The test now checks the parent element for styling classes, which is correct since TruncatedText wraps the text in an additional span. The styling classes
cursor-defaultandfont-semiboldare applied to the parent span (line 32 in BreadCrumbs.tsx), so this assertion properly validates the expected behavior.
kasya
left a comment
There was a problem hiding this comment.
@anurag2787 this looks great! Thank you!
Co-authored-by: anurag2787 <anurag2787@gmail.com>



Resolves #2960
Description
This PR fixes an issue where long chapter names cause the breadcrumb to overflow and break the layout on smaller screens.
Checklist
make check-testlocally and all tests passed