Skip to content

fix(visualization): auto-close File Explorer sort dropdown - #4478

Merged
ChristianHuehn merged 1 commit into
mainfrom
fix/explorer-sort-dropdown-auto-close
May 7, 2026
Merged

fix(visualization): auto-close File Explorer sort dropdown#4478
ChristianHuehn merged 1 commit into
mainfrom
fix/explorer-sort-dropdown-auto-close

Conversation

@ChristianHuehn

@ChristianHuehn ChristianHuehn commented May 6, 2026

Copy link
Copy Markdown
Collaborator

Migrate the daisyUI sort dropdown from pure-CSS focus-within to a controlled signal pattern (isOpen + document:click HostListener), matching MapSelector / DeltaSelector. The menu now closes after the user picks a sort key, toggles the order, or clicks outside.

{Meaningful title}

Please read the CONTRIBUTING.md before opening a PR.

Closes: #

Description

Descriptive pull request text, answering:

  • What problem/issue are you fixing?
  • What does this PR implement and how?

Definition of Done

A PR is only ready for merge once all the following acceptance criteria are fulfilled:

  • Changes have been manually tested
  • All TODOs related to this PR have been closed
  • There are automated tests for newly written code and bug fixes
  • All bugs discovered while working on this PR have been submitted as issues (if not already an open issue)
  • Documentation (GH-pages, analysis/visualization READMEs, parser READMEs, --help, etc.) has been updated (almost always necessary except for bug fixes)
  • CHANGELOG.md has been updated

Screenshots or gifs

Summary by CodeRabbit

  • Bug Fixes
    • File Explorer sort dropdown now automatically closes after selecting a sort key or toggling sort order, and also closes when clicking outside the menu.

Migrate the daisyUI sort dropdown from pure-CSS focus-within to a
controlled signal pattern (isOpen + document:click HostListener),
matching MapSelector / DeltaSelector. The menu now closes after the
user picks a sort key, toggles the order, or clicks outside.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented May 6, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This PR adds auto-close functionality to the File Explorer sort dropdown by converting it from a CSS-driven dropdown to a controlled-signal pattern. The implementation adds an isOpen signal to manage visibility, wires toggle and outside-click handlers, updates the template to render conditionally, closes the dropdown after actions, and adds comprehensive tests.

Changes

Explorer Sort Dropdown Auto-Close

Layer / File(s) Summary
Plan & Architecture
plans/2026-05-06-explorer-sort-dropdown-auto-close.md
Comprehensive plan documenting the controlled-signal pattern adoption, current state analysis, desired behavior, affected files, component sketches, task checklist, and migration notes.
State Management
visualization/app/codeCharta/features/sidebarExplorer/components/explorerSortControl/explorerSortControl.component.ts (lines 15-15)
Introduces isOpen signal initialized to false to track dropdown visibility state.
Core Toggle & Outside-Click Logic
visualization/app/codeCharta/features/sidebarExplorer/components/explorerSortControl/explorerSortControl.component.ts (lines 1, 13, 22-34)
Injects ElementRef, adds toggleOpen() method to flip visibility state, and adds handleDocumentClick() HostListener to close dropdown when clicking outside the component.
Template Wiring
visualization/app/codeCharta/features/sidebarExplorer/components/explorerSortControl/explorerSortControl.component.html
Binds container class to isOpen(), adds click handler to trigger button calling toggleOpen(), and wraps option list in conditional @if (isOpen()) block.
Integration with Existing Actions
visualization/app/codeCharta/features/sidebarExplorer/components/explorerSortControl/explorerSortControl.component.ts (lines 36-43)
Updates setSortingOption() and toggleSortOrder() to close the dropdown by setting isOpen to false after performing their actions.
Tests & Documentation
visualization/app/codeCharta/features/sidebarExplorer/components/explorerSortControl/explorerSortControl.component.spec.ts, visualization/CHANGELOG.md
Adds comprehensive test coverage for initial hidden state, option visibility, selection behavior with auto-close, sort-order toggle with auto-close, and outside-click dismissal; updates changelog to document the fix.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A dropdown that dances with signals so bright,
Closes on command, no CSS sleight!
Click the trigger, the menu appears,
Select your choice and it vanishes, my dear.
Outside clicks too—a tidy, controlled sight!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The PR title clearly and concisely describes the main change: auto-closing the File Explorer sort dropdown, which matches the core functionality implemented across multiple component files.
Description check ✅ Passed The PR description explains the problem (migration from CSS focus-within to controlled signal pattern), the solution approach (isOpen signal + HostListener), and mentions pattern alignment with similar components. However, the template structure is partially corrupted with duplicate headers and incomplete checklist items.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/explorer-sort-dropdown-auto-close

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.

@sonarqubecloud

sonarqubecloud Bot commented May 6, 2026

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@plans/2026-05-06-explorer-sort-dropdown-auto-close.md`:
- Line 59: Add explicit language identifiers to the three fenced code blocks
(lines showing the dropdown ASCII art and the component snippet) to satisfy
MD040: change the plain ``` fences to ```text for the two ASCII UI examples (the
block showing the dropdown before and after selection) and to ```ts for the
TypeScript/Angular-like snippet (the block containing isOpen = signal(false),
`@HostListener`, toggleOpen(), etc.); update the three fences that currently are
just ``` to use those language tags so markdown linting passes.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b43b9cac-8fba-4ada-ab3b-861b7881ff57

📥 Commits

Reviewing files that changed from the base of the PR and between 4e006b3 and 7708617.

📒 Files selected for processing (5)
  • plans/2026-05-06-explorer-sort-dropdown-auto-close.md
  • visualization/CHANGELOG.md
  • visualization/app/codeCharta/features/sidebarExplorer/components/explorerSortControl/explorerSortControl.component.html
  • visualization/app/codeCharta/features/sidebarExplorer/components/explorerSortControl/explorerSortControl.component.spec.ts
  • visualization/app/codeCharta/features/sidebarExplorer/components/explorerSortControl/explorerSortControl.component.ts


### Before — bug

```

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Add language identifiers to fenced code blocks to satisfy markdown linting.

Line 59, Line 72, and Line 91 use fenced blocks without a language tag (MD040).

🛠️ Suggested patch
-```
+```text
 Sort: Name  ▾ ↓                    ← user clicks dropdown
   ┌────────────────────────────┐
   │ Name                       │  ← user clicks "Number of files"
   │ Number of files            │  ← dropdown STAYS OPEN
   │ Area Size                  │
   │ ────────────────────────── │
   │ ↑ Sort descending          │
   └────────────────────────────┘

- +text
Sort: Name ▾ ↓ ← user clicks dropdown (open)
┌────────────────────────────┐
│ Name │
│ Number of files │ ← user clicks "Number of files"
│ Area Size │
│ ────────────────────────── │
│ ↑ Sort descending │
└────────────────────────────┘

Sort: Number of files ▾ ↓ ← dropdown CLOSED, label updated


-```
+```ts
isOpen = signal(false)
[class.dropdown-open]="isOpen()"  on outer .dropdown
`@if` (isOpen()) { <dropdown-content/> }   ← optional but matches the two reference components
`@HostListener`("document:click")     ← close on outside click
toggleOpen() / item-handlers .set(false) on dropdown close
</details>


Also applies to: 72-72, 91-91

<details>
<summary>🧰 Tools</summary>

<details>
<summary>🪛 markdownlint-cli2 (0.22.1)</summary>

[warning] 59-59: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

</details>

</details>

<details>
<summary>🤖 Prompt for AI Agents</summary>

Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @plans/2026-05-06-explorer-sort-dropdown-auto-close.md at line 59, Add
explicit language identifiers to the three fenced code blocks (lines showing the
dropdown ASCII art and the component snippet) to satisfy MD040: change the plain
fences totext for the two ASCII UI examples (the block showing the
dropdown before and after selection) and to ts for the TypeScript/Angular-like snippet (the block containing isOpen = signal(false), `@HostListener`, toggleOpen(), etc.); update the three fences that currently are just to use those language tags so markdown linting passes.


</details>

<!-- fingerprinting:phantom:poseidon:hawk -->

<!-- d98c2f50 -->

<!-- This is an auto-generated comment by CodeRabbit -->

@ChristianHuehn
ChristianHuehn merged commit a97bb47 into main May 7, 2026
8 of 9 checks passed
@ChristianHuehn
ChristianHuehn deleted the fix/explorer-sort-dropdown-auto-close branch May 7, 2026 17:40
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.

2 participants