Skip to content

fix: auto-expand collapsed sidebar section when clicking action buttons#6468

Merged
sid-bruno merged 1 commit intousebruno:mainfrom
pooja-bruno:fix/sidebar-section-auto-expand-on-action-click
Dec 19, 2025
Merged

fix: auto-expand collapsed sidebar section when clicking action buttons#6468
sid-bruno merged 1 commit intousebruno:mainfrom
pooja-bruno:fix/sidebar-section-auto-expand-on-action-click

Conversation

@pooja-bruno
Copy link
Collaborator

@pooja-bruno pooja-bruno commented Dec 19, 2025

Description

When a sidebar section (Collections or API Specs) is collapsed and the user clicks on an action button (e.g., search, add, or menu), the section now automatically expands.

JIRA

Contribution Checklist:

  • I've used AI significantly to create this pull request
  • The pull request only addresses one issue or adds one feature.
  • The pull request does not introduce any breaking changes
  • I have added screenshots or gifs to help explain the change if applicable.
  • I have read the contribution guidelines.
  • Create an issue and link to the pull request.
Screen.Recording.2025-12-19.at.1.12.29.PM.mov

Summary by CodeRabbit

  • New Features

    • Sidebar sections now automatically expand when users click action buttons while sections are in a collapsed state, providing immediate access to expanded content and controls.
  • Tests

    • Added comprehensive test coverage validating sidebar section auto-expansion behavior when action buttons are triggered.

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 19, 2025

Walkthrough

This PR adds auto-expand functionality to sidebar sections. When clicking actions (e.g., add-menu) on a collapsed section, the section now automatically expands instead of remaining collapsed. The implementation modifies the onClick handler and includes comprehensive test coverage for the new behavior.

Changes

Cohort / File(s) Summary
Sidebar Section Auto-Expand Logic
packages/bruno-app/src/components/Sidebar/SidebarSection/index.js
Modified the actions area onClick handler to check if the section is collapsed and call setSectionExpanded(id, true) to expand it, while preserving existing event propagation stop.
Test Coverage
tests/sidebar/section-auto-expand.spec.ts
Added new Playwright test suite validating auto-expand behavior when clicking action buttons on collapsed sections, including API Specs and Collections sections.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Areas requiring attention:
    • Verify setSectionExpanded(id, true) is correctly gated by the collapsed state check to avoid unnecessary re-renders
    • Confirm test selectors robustly target the intended elements across different section types
    • Validate that the auto-expand doesn't interfere with other section interactions

Possibly related PRs

  • bruno#6373 — Introduces the SidebarSection and SidebarAccordionContext foundation that this PR builds upon to enable the auto-expand feature.

Suggested reviewers

  • helloanoop
  • Pragadesh44-Bruno

Poem

🎯 Collapsed sections now stand tall,
When actions clicked, they heed the call—
Expand and show your treasured find,
No more frustration, all aligned! 📂✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: auto-expansion of collapsed sidebar sections when action buttons are clicked, which is reflected in both modified files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ 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.

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

🧹 Nitpick comments (4)
packages/bruno-app/src/components/Sidebar/SidebarSection/index.js (1)

69-74: Consider updating local state immediately for consistency.

The onClick handler updates only the context via setSectionExpanded(id, true) and relies on the useEffect (lines 20-23) to sync localExpanded. In contrast, handleToggle (lines 25-29) updates both localExpanded and the context immediately.

For consistency and to avoid potential UI lag, consider updating localExpanded directly:

🔎 Proposed refactor for immediate state update
 onClick={(e) => {
   e.stopPropagation();
   if (!localExpanded) {
+    setLocalExpanded(true);
     setSectionExpanded(id, true);
   }
 }}
tests/sidebar/section-auto-expand.spec.ts (3)

4-29: Use test.step to improve test readability.

Per coding guidelines, test.step should be used to organize test actions and make reports easier to read. Consider restructuring this test with steps like "Verify section is initially collapsed", "Click action button", and "Verify section expands".

🔎 Proposed refactor with test.step
 test('Clicking action button on collapsed section should expand it', async ({ page }) => {
-  // The api-specs section is collapsed by default (only collections is expanded)
-  // Find the api-specs section by its title
-  const apiSpecsSection = page.locator('.sidebar-section').filter({ hasText: 'API Specs' });
-
-  // Verify the api-specs section is initially collapsed (doesn't have 'expanded' class)
-  await expect(apiSpecsSection).not.toHaveClass(/expanded/);
-
-  // Verify section-content is not visible when collapsed
-  const sectionContent = apiSpecsSection.locator('.section-content');
-  await expect(sectionContent).not.toBeVisible();
-
-  // Click on the add button in the section-actions area
-  // This should trigger the auto-expand logic
-  const addButton = page.getByTestId('api-specs-header-add-menu');
-  await addButton.click();
-
-  // Close the dropdown by pressing Escape (we just want to test the expand, not the dropdown action)
-  await page.keyboard.press('Escape');
-
-  // After clicking an action, the section should be expanded
-  await expect(apiSpecsSection).toHaveClass(/expanded/);
-
-  // Verify section-content is now visible
-  await expect(sectionContent).toBeVisible();
+  await test.step('Verify API Specs section is initially collapsed', async () => {
+    const apiSpecsSection = page.locator('.sidebar-section').filter({ hasText: 'API Specs' });
+    await expect(apiSpecsSection).not.toHaveClass(/expanded/);
+    
+    const sectionContent = apiSpecsSection.locator('.section-content');
+    await expect(sectionContent).not.toBeVisible();
+  });
+
+  await test.step('Click action button to trigger auto-expand', async () => {
+    const addButton = page.getByTestId('api-specs-header-add-menu');
+    await addButton.click();
+    await page.keyboard.press('Escape');
+  });
+
+  await test.step('Verify section is now expanded', async () => {
+    const apiSpecsSection = page.locator('.sidebar-section').filter({ hasText: 'API Specs' });
+    await expect(apiSpecsSection).toHaveClass(/expanded/);
+    
+    const sectionContent = apiSpecsSection.locator('.section-content');
+    await expect(sectionContent).toBeVisible();
+  });
 });

Note: You'll need to move locator declarations to be accessible across steps or redeclare them as shown.

Based on coding guidelines: "Promote the use of test.step as much as possible so the generated reports are easier to read."


31-52: Use test.step to improve test readability.

Apply the same test.step pattern here to organize the test into logical sections: verify initial state, perform action, verify final state.

Based on coding guidelines: "Promote the use of test.step as much as possible so the generated reports are easier to read."


54-73: Use test.step to improve test readability.

This test would benefit from steps like "Collapse Collections section", "Click search action button", and "Verify section expands". This makes the test flow clearer in reports.

Based on coding guidelines: "Promote the use of test.step as much as possible so the generated reports are easier to read."

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3552e7e and d46e877.

📒 Files selected for processing (2)
  • packages/bruno-app/src/components/Sidebar/SidebarSection/index.js (1 hunks)
  • tests/sidebar/section-auto-expand.spec.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (CODING_STANDARDS.md)

**/*.{js,jsx,ts,tsx}: Use 2 spaces for indentation. No tabs, just spaces
Stick to single quotes for strings. For JSX/TSX attributes, use double quotes (e.g., )
Always add semicolons at the end of statements
No trailing commas
Always use parentheses around parameters in arrow functions, even for single params
For multiline constructs, put opening braces on the same line, and ensure consistency. Minimum 2 elements for multiline
No newlines inside function parentheses
Space before and after the arrow in arrow functions. () => {} is good
No space between function name and parentheses. func() not func ()
Semicolons go at the end of the line, not on a new line
Names for functions need to be concise and descriptive
Add in JSDoc comments to add more details to the abstractions if needed
Add in meaningful comments instead of obvious ones where complex code flow is explained properly

Files:

  • packages/bruno-app/src/components/Sidebar/SidebarSection/index.js
  • tests/sidebar/section-auto-expand.spec.ts
tests/**/**.*

⚙️ CodeRabbit configuration file

tests/**/**.*: Review the following e2e test code written using the Playwright test library. Ensure that:

  • Follow best practices for Playwright code and e2e automation

  • Try to reduce usage of page.waitForTimeout(); in code unless absolutely necessary and the locator cannot be found using existing expect() playwright calls

  • Avoid using page.pause() in code

  • Use locator variables for locators

  • Avoid using test.only

  • Use multiple assertions

  • Promote the use of test.step as much as possible so the generated reports are easier to read

  • Ensure that the fixtures like the collections are nested inside the fixtures folder

    Fixture Example*: Here's an example of possible fixture and test pair

    .
    ├── fixtures
    │   └── collection
    │       ├── base.bru
    │       ├── bruno.json
    │       ├── collection.bru
    │       ├── ws-test-request-with-headers.bru
    │       ├── ws-test-request-with-subproto.bru
    │       └── ws-test-request.bru
    ├── connection.spec.ts # <- Depends on the collection in ./fixtures/collection
    ├── headers.spec.ts
    ├── persistence.spec.ts
    ├── variable-interpolation
    │   ├── fixtures
    │   │   └── collection
    │   │       ├── environments
    │   │       ├── bruno.json
    │   │       └── ws-interpolation-test.bru
    │   ├── init-user-data
    │   └── variable-interpolation.spec.ts # <- Depends on the collection in ./variable-interpolation/fixtures/collection
    └── subproto.spec.ts
    

Files:

  • tests/sidebar/section-auto-expand.spec.ts
🧠 Learnings (2)
📚 Learning: 2025-12-17T21:41:24.730Z
Learnt from: naman-bruno
Repo: usebruno/bruno PR: 6407
File: packages/bruno-app/src/components/Environments/ConfirmCloseEnvironment/index.js:5-41
Timestamp: 2025-12-17T21:41:24.730Z
Learning: Do not suggest PropTypes validation for React components in the Bruno codebase. The project does not use PropTypes, so reviews should avoid proposing PropTypes and rely on the existing typing/validation approach (e.g., TypeScript or alternative runtime checks) if applicable. This guideline applies broadly to all JavaScript/JSX components in the repo.

Applied to files:

  • packages/bruno-app/src/components/Sidebar/SidebarSection/index.js
📚 Learning: 2025-12-05T20:31:33.005Z
Learnt from: CR
Repo: usebruno/bruno PR: 0
File: CODING_STANDARDS.md:0-0
Timestamp: 2025-12-05T20:31:33.005Z
Learning: Applies to **/*.test.{js,jsx,ts,tsx} : Add tests for any new functionality or meaningful changes. If code is added, removed, or significantly modified, corresponding tests should be updated or created

Applied to files:

  • tests/sidebar/section-auto-expand.spec.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: Unit Tests
  • GitHub Check: SSL Tests - Windows
  • GitHub Check: CLI Tests
  • GitHub Check: Playwright E2E Tests
  • GitHub Check: SSL Tests - macOS
  • GitHub Check: SSL Tests - Linux

@sid-bruno sid-bruno merged commit 5f88e7d into usebruno:main Dec 19, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants