Skip to content

Conversation

@adityathebe
Copy link
Member

@adityathebe adityathebe commented Dec 3, 2025

resolves: #2742

Summary by CodeRabbit

  • New Features

    • Sections are now collapsible with toggle icons and keyboard activation (Enter/Space); expanded sections reveal content on demand and show loading skeletons while loading.
  • Bug Fixes

    • Section titles now display correctly instead of appearing empty.
    • Error messages are revealed when expanding sections that encounter issues.
  • UI/Style

    • Adjusted container padding and top spacing for cleaner layout.
    • Reduced vertical spacing between sections for a more compact view.

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

@vercel
Copy link

vercel bot commented Dec 3, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Updated (UTC)
aws-preview Ready Ready Preview Dec 4, 2025 8:01am
flanksource-ui Ready Ready Preview Dec 4, 2025 8:01am

@coderabbitai
Copy link

coderabbitai bot commented Dec 3, 2025

Walkthrough

Adjusts SingleView layout and derives the primary title from data; adds collapsible behavior to view sections with local expand/collapse state, interactive and keyboard-accessible headers, chevron indicator, conditional loading/error UI, and gated rendering of View content.

Changes

Cohort / File(s) Summary
Layout & title
src/pages/views/components/SingleView.tsx
Primary title now sourced from data (`title
Collapse / interactive section
src/pages/views/components/ViewSection.tsx
Adds isExpanded state with useState; makes header clickable and keyboard-accessible (Enter/Space) to toggle expansion; adds IoChevronDownOutline chevron that reflects expanded state; content (loading skeleton, error UI, and View) is rendered only when expanded.
Minor layout tweak
src/pages/audit-report/components/View/GlobalFilters.tsx
Outer container gains mt-4 in addition to existing mb-4; no control-flow or data handling changes.

Possibly related PRs

  • feat: view sections #2739: Related work touching ViewSection and SingleView features (per-section handling and layout) that may overlap with the new collapsible header behavior.

Suggested reviewers

  • moshloop

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat(view): Collapsible section' accurately summarizes the main change: adding collapsible functionality to view sections.
Linked Issues check ✅ Passed The code changes implement collapsible view sections with keyboard accessibility and visual indicators, directly addressing the linked issue #2742.
Out of Scope Changes check ✅ Passed All changes are scoped to implementing collapsible sections. Minor layout adjustments in SingleView.tsx and GlobalFilters.tsx support the primary feature.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/collapsible-view-section

📜 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 87cb15a and 3592ab4.

📒 Files selected for processing (2)
  • src/pages/audit-report/components/View/GlobalFilters.tsx (1 hunks)
  • src/pages/views/components/ViewSection.tsx (3 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/pages/views/components/ViewSection.tsx (1)
src/api/services/views.ts (1)
  • View (7-19)
🔇 Additional comments (8)
src/pages/audit-report/components/View/GlobalFilters.tsx (1)

75-75: LGTM: Spacing adjustment aligns with layout refinements.

The additional top margin provides better visual separation and aligns with the broader layout adjustments in this PR.

src/pages/views/components/ViewSection.tsx (7)

1-3: LGTM: Imports support the collapsible functionality.

The useState hook and IoChevronDownOutline icon are properly imported to support the new collapsible section feature.


20-20: LGTM: Default expanded state provides good UX.

Initializing sections as expanded ensures users see content immediately without requiring an additional click.


42-47: LGTM: Proper keyboard accessibility implementation.

The keyboard handler correctly implements the button pattern by responding to Enter and Space keys, and properly prevents default behavior to avoid page scrolling.


49-50: LGTM: Loading state logic fix addresses previous issue.

The condition now correctly differentiates between loading and error states by checking !isLoading before treating missing data as an error. This resolves the issue where the loading skeleton was unreachable.


53-79: LGTM: Error UI implements complete accessibility.

The error header now includes all required accessibility attributes (role="button", tabIndex={0}, aria-expanded, aria-controls) and keyboard handlers, fully addressing the previous accessibility concerns. The collapsible error message properly links to the header via matching IDs.


88-107: LGTM: Success header implements complete accessibility.

The interactive header includes all required accessibility attributes and properly links to the collapsible content via aria-controls. The chevron rotation provides clear visual feedback for the expansion state.


108-131: LGTM: Content area properly handles loading and data states.

The collapsible content correctly shows a loading skeleton during data fetch and renders the View component when ready. The empty title passed to View (line 117) is appropriate since the section title is now displayed in the ViewSection header, avoiding duplication.


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.

Copy link

@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: 1

🧹 Nitpick comments (1)
src/pages/views/components/ViewSection.tsx (1)

45-61: Extract duplicated header into a reusable component.

The header rendering logic is duplicated between the error case (lines 45-61) and success case (lines 73-87). This violates DRY principles and makes maintenance harder.

Consider extracting the header into a separate component or at least into a helper function to eliminate duplication:

const CollapsibleHeader: React.FC<{
  isExpanded: boolean;
  onToggle: () => void;
  icon?: string;
  title: string;
}> = ({ isExpanded, onToggle, icon, title }) => (
  <div
    className="mb-2 flex cursor-pointer items-center gap-2 rounded px-2 py-1"
    role="button"
    tabIndex={0}
    onKeyDown={(e) => {
      if (e.key === 'Enter' || e.key === ' ') {
        e.preventDefault();
        onToggle();
      }
    }}
    onClick={onToggle}
  >
    <IoChevronDownOutline
      className={`h-4 w-4 flex-shrink-0 transform text-gray-600 transition-transform ${!isExpanded ? "-rotate-90" : ""}`}
    />
    {icon && (
      <Icon
        name={icon}
        className="h-5 w-5 flex-shrink-0 text-gray-600"
      />
    )}
    <h3 className="text-lg font-semibold text-gray-600">{title}</h3>
  </div>
);

Also applies to: 73-87

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7e8b094 and 1b6f186.

📒 Files selected for processing (2)
  • src/pages/views/components/SingleView.tsx (4 hunks)
  • src/pages/views/components/ViewSection.tsx (3 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/pages/views/components/ViewSection.tsx (1)
src/api/services/views.ts (1)
  • View (7-19)
🔇 Additional comments (7)
src/pages/views/components/ViewSection.tsx (3)

1-1: LGTM: New imports and state initialization.

The useState hook and IoChevronDownOutline icon imports are correctly added, and initializing sections to expanded (true) provides good default UX.

Also applies to: 3-3, 20-20


62-66: Verify: Error visibility when section is collapsed.

Error messages are only displayed when the section is expanded. While sections start expanded by default, if a user collapses a section with an error, that error becomes hidden. This could prevent users from noticing critical issues.

Consider these alternatives:

  1. Add a visual indicator (e.g., red color, warning icon) to the header when an error exists, even when collapsed
  2. Always show errors regardless of expansion state
  3. Keep current behavior if hiding errors is intentional for UX reasons

Which approach aligns best with the intended user experience?


88-108: LGTM: Conditional rendering with loading state.

The conditional rendering logic correctly handles both loading and loaded states when expanded. The loading skeleton provides good UX feedback, and passing an empty string for title (line 96) is appropriate since the title is already displayed in the section header.

src/pages/views/components/SingleView.tsx (4)

166-166: LGTM: Primary section now has meaningful title.

Changing the primary view section title from an empty string to title || name ensures the collapsible header displays a meaningful title, consistent with how additional sections are handled.


188-188: LGTM: Padding adjustment aligns with collapsible sections.

The change from p-6 pb-0 to px-6 removes vertical padding, which is appropriate since the collapsible sections now manage their own spacing internally. Horizontal padding is preserved for proper content alignment.


204-204: LGTM: Top margin added for primary section.

Adding mt-2 provides appropriate spacing above the primary view section, complementing the padding changes on the parent container.


217-217: LGTM: Reduced section spacing aligns with collapsible design.

The spacing reduction from mt-6 pt-6 (48px) to mt-4 (16px) is appropriate for the new collapsible sections. Each section now has its own distinct header, reducing the need for excessive vertical separation. This prevents large gaps when sections are collapsed.

Copy link

@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: 1

♻️ Duplicate comments (1)
src/pages/views/components/ViewSection.tsx (1)

53-61: Keyboard accessibility properly implemented.

The accessibility attributes (role="button", tabIndex={0}, aria-expanded, aria-controls) and keyboard handler have been added as requested in the previous review.

🧹 Nitpick comments (2)
src/pages/views/components/ViewSection.tsx (2)

116-128: Minor inconsistency in optional chaining usage.

Line 125 uses sectionViewResult.requestFingerprint without optional chaining while other props use ?.. While sectionViewResult is guaranteed to exist here, consider using consistent access patterns for maintainability.

-              requestFingerprint={sectionViewResult.requestFingerprint}
+              requestFingerprint={sectionViewResult?.requestFingerprint}

88-107: Consider extracting the header into a reusable component.

The header rendering (chevron, icon, title) is duplicated between the error path (lines 53-74) and success path (lines 88-107). Extracting to a SectionHeader component would reduce duplication.

const SectionHeader: React.FC<{
  section: Section;
  isExpanded: boolean;
  onToggle: () => void;
  onKeyDown: (e: React.KeyboardEvent<HTMLDivElement>) => void;
  contentId: string;
}> = ({ section, isExpanded, onToggle, onKeyDown, contentId }) => (
  <div
    role="button"
    tabIndex={0}
    aria-expanded={isExpanded}
    aria-controls={contentId}
    className="mb-2 flex cursor-pointer items-center gap-2 rounded px-2 py-1"
    onClick={onToggle}
    onKeyDown={onKeyDown}
  >
    <IoChevronDownOutline
      className={`h-4 w-4 flex-shrink-0 transform text-gray-600 transition-transform ${!isExpanded ? "-rotate-90" : ""}`}
    />
    {section.icon && (
      <Icon name={section.icon} className="h-5 w-5 flex-shrink-0 text-gray-600" />
    )}
    <h3 className="text-lg font-semibold text-gray-600">{section.title}</h3>
  </div>
);
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1b6f186 and 87cb15a.

📒 Files selected for processing (1)
  • src/pages/views/components/ViewSection.tsx (3 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/pages/views/components/ViewSection.tsx (1)
src/api/services/views.ts (1)
  • View (7-19)
🔇 Additional comments (2)
src/pages/views/components/ViewSection.tsx (2)

1-20: LGTM!

Clean setup for the collapsible state. Starting with sections expanded by default is good UX for first-time viewers.


42-47: LGTM!

Keyboard handler correctly implements accessibility best practices - handling both Enter and Space with proper preventDefault to avoid scroll behavior.

@moshloop moshloop merged commit f501bf6 into main Dec 4, 2025
14 of 16 checks passed
@moshloop moshloop deleted the feat/collapsible-view-section branch December 4, 2025 09:24
@netlify
Copy link

netlify bot commented Dec 5, 2025

Deploy Preview for flanksource-demo-stable failed. Why did it fail? →

Name Link
🔨 Latest commit 3592ab4
🔍 Latest deploy log https://app.netlify.com/projects/flanksource-demo-stable/deploys/69313f022c067a00089fa582

@netlify
Copy link

netlify bot commented Dec 5, 2025

Deploy Preview for clerk-saas-ui failed. Why did it fail? →

Name Link
🔨 Latest commit 3592ab4
🔍 Latest deploy log https://app.netlify.com/projects/clerk-saas-ui/deploys/69313f02563e3e00085a6b80

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.

View Section | Collapsible

3 participants