website icon indicating copy to clipboard operation
website copied to clipboard

fix: error handling on empty array

Open Ayush4958 opened this issue 4 weeks ago • 3 comments

🐛 Issue

When the items array is empty, the roadmap component renders an unintended "0" character on the UI. This happens due to conditional rendering logic evaluating to a numeric value instead of returning null.

✅ Fix Updated the component’s rendering logic to explicitly handle the empty state.

  • When items.length == 0, the component now returns null
  • Prevents any unintended visual output
  • Ensures consistent and predictable rendering behavior

🔄 Before A "0" character was displayed on the roadmap page when the items array was empty. WhatsApp Image 2025-12-18 at 5 03 13 PM (1)

✨ After

  • The component renders nothing when the items array is empty, as expected. WhatsApp Image 2025-12-18 at 5 03 13 PM

🧪 Testing

  • Verified rendering with:
  • Empty items array
  • Non-empty items array
  • Confirmed no regression in existing behavior

Related issue(s) Fixes for #4729

Summary by CodeRabbit

  • Bug Fixes
    • Improved empty state handling to display a placeholder message instead of blank areas when no content is available.

✏️ Tip: You can customize this high-level summary in your review settings.

Ayush4958 avatar Dec 19 '25 14:12 Ayush4958

Deploy Preview for asyncapi-website ready!

Built without sensitive environment variables

Name Link
Latest commit 018b8dab61953459f2774a433687364be9409719
Latest deploy log https://app.netlify.com/projects/asyncapi-website/deploys/694d0af7e0d5e7000846ef63
Deploy Preview https://deploy-preview-4747--asyncapi-website.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 project configuration.

netlify[bot] avatar Dec 19 '25 14:12 netlify[bot]

Walkthrough

Added an early guard condition in RoadmapList to handle empty or undefined items by rendering a placeholder paragraph ("🛠 Actively Developing") instead of proceeding with list rendering. Existing behavior is preserved when items are present. No public API changes.

Changes

Cohort / File(s) Change Summary
Conditional Rendering for Empty State
components/roadmap/RoadmapList.tsx
Added early guard to render placeholder paragraph when items are empty or undefined; preserves existing list rendering for non-empty items

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Single-file change with straightforward conditional logic
  • Verify placeholder text is appropriate and consistent with design language
  • Confirm empty/undefined conditions are correctly handled

Possibly related issues

  • asyncapi/website#4729: Both changes affect the same component (components/roadmap/RoadmapList.tsx) and address conditional rendering behavior for empty or undefined items—this PR may directly resolve or relate to that issue's objectives.

Poem

🐰✨ A rabbit hopped through empty states,
With guards so swift, no more it waits—
"Actively Developing!" now the cry,
When lists are bare, a placeholder spry! 🛠️

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: error handling on empty array' directly addresses the main change: adding guard logic to handle empty items in RoadmapList, which prevents unintended rendering when the array is empty.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • [ ] 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • [ ] Create PR with unit tests
  • [ ] Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar Dec 19 '25 14:12 coderabbitai[bot]

⚡️ Lighthouse report for the changes in this PR:

Category Score
🔴 Performance 38
🟢 Accessibility 98
🟢 Best practices 92
🟢 SEO 100
🔴 PWA 33

Lighthouse ran on https://deploy-preview-4747--asyncapi-website.netlify.app/

asyncapi-bot avatar Dec 19 '25 14:12 asyncapi-bot

Hi @Ayush4958, thanks for the effort on this PR 🙌 Just a quick note — the same issue was already fixed and merged in #4745, so this PR may be a duplicate.

Sam-61s avatar Dec 24 '25 02:12 Sam-61s