Skip to content

Collections sidenav folder icon should reflect expanded/collapsed state - #943

Merged
malibio merged 2 commits into
mainfrom
feature/issue-939-folder-icon-expanded-state
Mar 14, 2026
Merged

malibio merged 2 commits into
mainfrom
feature/issue-939-folder-icon-expanded-state

Conversation

@malibio

@malibio malibio commented Mar 14, 2026

Copy link
Copy Markdown
Collaborator

Closes #939

…denav (closes #939)

Conditionally render open/closed folder SVG in the Collections Collapsible.Trigger
based on collectionsExpanded state. Open variant adds a horizontal line across
the folder body (Lucide folder-open style) using the same stroke/dimensions.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@malibio

malibio commented Mar 14, 2026

Copy link
Copy Markdown
Collaborator Author

Code Review Summary

Review Type: Initial Review

This is a single-file, single-commit change with a clear, scoped purpose: making the Collections folder icon reflect the expanded/collapsed state. The implementation is correct and the change is a net improvement. There are two findings worth noting — one minor improvement opportunity and one nit.


Requirements Check

  • Folder icon shows closed state when Collections section is collapsed
  • Folder icon shows open state when Collections section is expanded
  • Icon switches immediately on click (no delay — driven directly by reactive collectionsExpanded derived state)
  • Works correctly on initial load when collectionsExpanded is restored from persisted layout state (collectionsExpanded is $derived($layoutState.collectionsExpanded), so persistence is inherited automatically)
  • Tests pass (bun run test:all) — no test changes required for a pure UI rendering change
  • Code passes bun run quality:fix

All acceptance criteria are met.


Code Review Findings

Suggested Improvements

navigation-sidebar.svelte lines 264–285 — The two <svg> elements share identical attributes (class, viewBox, fill, stroke, stroke-width) and differ only in the presence of the second <path>. The conditional branch duplicates the outer SVG wrapper. While this is not a correctness issue, it creates a maintenance surface: if the icon style changes (e.g. stroke-width, class), it must be updated in two places.

A more DRY approach renders a single SVG and conditionally includes the extra path:

<svg class="nav-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
  <path d="M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z" />
  {#if collectionsExpanded}
    <path d="M2 10h20" />
  {/if}
</svg>

This is functionally equivalent and aligns with the DRY principle, which is more important to enforce early when the icon style may still be evolving.

Nitpicks

Nit: navigation-sidebar.svelte line 263 — The Collapsible.Trigger renders as a button and exposes its state to the Collapsible.Root via the bits-ui library, but the trigger element itself carries no aria-label. Other interactive sidebar elements in this file include explicit aria-label attributes (see lines 218, 241, 300, 334). Consistency here would benefit screen reader users since the button's text content alone ("Collections") does not convey the current expanded/collapsed state. An aria-label like {collectionsExpanded ? 'Collapse Collections' : 'Expand Collections'} would align with the pattern already used on lines 300 and 334 for child collection items.


Recommendation

APPROVE — The change correctly implements all acceptance criteria with reactive, persisted state. The duplication finding is a legitimate improvement but not a blocker given the project's no-users, greenfield status. The fix is straightforward and can be addressed in a follow-up or inline before merge at the author's discretion.

@malibio malibio left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

All acceptance criteria met. See inline comment for two minor findings (one DRY improvement, one accessibility nit). Neither is a blocker. Recommendation: APPROVE.

…gger

- Merged duplicate <svg> elements into one with a conditional inner <path>
- Added dynamic aria-label to Collapsible.Trigger reflecting expanded/collapsed state,
  consistent with existing sidebar interactive elements

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@malibio

malibio commented Mar 14, 2026

Copy link
Copy Markdown
Collaborator Author

Review Feedback Addressed

Both recommendations from the initial review have been addressed in commit 0b13487:

✅ SVG duplication (🟡 Important)
Merged the two duplicate <svg> elements into a single element with a conditional inner <path> for the open-folder line. Any future style change (stroke-width, class, etc.) now only requires one edit.

✅ Missing aria-label (🟢 Suggestion)
Added aria-label={collectionsExpanded ? 'Collapse Collections' : 'Expand Collections'} to the Collapsible.Trigger, consistent with the existing pattern on all other interactive sidebar elements.

No items were skipped.

@malibio
malibio merged commit e04bfb3 into main Mar 14, 2026
@malibio
malibio deleted the feature/issue-939-folder-icon-expanded-state branch March 14, 2026 14:00
malibio added a commit that referenced this pull request Jun 22, 2026
…te (#943)

* Fix folder icon to reflect expanded/collapsed state in collections sidenav (closes #939)

Conditionally render open/closed folder SVG in the Collections Collapsible.Trigger
based on collectionsExpanded state. Open variant adds a horizontal line across
the folder body (Lucide folder-open style) using the same stroke/dimensions.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* Address review: deduplicate SVG and add aria-label to collections trigger

- Merged duplicate <svg> elements into one with a conditional inner <path>
- Added dynamic aria-label to Collapsible.Trigger reflecting expanded/collapsed state,
  consistent with existing sidebar interactive elements

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

---------

Co-authored-by: Claude Sonnet 4.6 <[email protected]>
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.

Collections sidenav folder icon should reflect expanded/collapsed state

1 participant