[BUG] RoadmapList component renders "0" when items array is empty
Describe the bug.
The RoadmapList component uses a problematic conditional rendering pattern that can cause the number "0" to be displayed on the page when the items array is empty.
Location: components/roadmap/RoadmapList.tsx
Problematic Code: return ( items && items.length && ( <ul className={className} data-testid='RoadmapList-list'> {/* ... */} ) );
Expected behavior
When the items array is empty or undefined, the component should render nothing (return null) instead of displaying "0".
if (!items || items.length === 0) return null;
return (
-
{/* ... */}
This ensures that:
- No visual artifacts are displayed when there are no items
- The code is more readable and follows React best practices
- The intent is explicit and clear to other developers
Screenshots
Before Fix:
- A "0" character appears on the roadmap page when the items array is empty
After Fix:
- The component renders nothing (no visual output) when items array is empty
How to Reproduce
- Navigate to a roadmap page that uses the
RoadmapListcomponent - Ensure the
itemsprop passed toRoadmapListis an empty array[]orundefined - Observe that the number "0" is rendered on the page
Code to reproduce: // In a component that uses RoadmapList <RoadmapList colorClass="some-class" items={[]} // Empty array />
🖥️ Device Information [optional]
- Operating System (OS):
- Browser:
- Browser Version:
👀 Have you checked for similar open issues?
- [x] I checked and didn't find similar issue
🏢 Have you read the Contributing Guidelines?
- [x] I have read the Contributing Guidelines
Are you willing to work on this issue ?
Yes I am willing to submit a PR!
Hey @princerajpoot20
Could you please assign this issue to me so I can create a PR? I'm ready to submit it once assigned. Thanks! 🙏
Can i work on this issue ?
Hey @Dsp023 👋 Thanks for your interest! I’ve already requested assignment from the maintainer and am currently waiting for their approval. Once they respond, I'll proceed accordingly. Appreciate your understanding! 🙏
Hi @Sam-61s👋 I’ve gone through this issue and understand the root cause and expected behavior. I’d love to work on this and submit a clean fix that aligns with the project’s existing patterns and best practices.
If this issue is still unassigned, please feel free to assign it to me. Happy to ask clarifying questions or adjust the solution based on maintainer feedback.
Thanks! 🙌