Skip to content

fix(datagrid): render sort chevron via SF Symbol with palette tint#948

Merged
datlechin merged 4 commits intomainfrom
fix/sort-chevron-sf-symbol
Apr 29, 2026
Merged

fix(datagrid): render sort chevron via SF Symbol with palette tint#948
datlechin merged 4 commits intomainfrom
fix/sort-chevron-sf-symbol

Conversation

@datlechin
Copy link
Copy Markdown
Member

Summary

Fixes a Dark mode regression introduced by #945. The sort chevron was invisible in Dark mode (visible in Light mode).

Root cause

SortableHeaderCell.drawInterior used the private AppKit SPI images NSAscendingSortIndicator / NSDescendingSortIndicator. These are template images. The helper function drawTintedIndicator was misleadingly named — it didn't actually tint anything, it just called image.draw(in:...). Template images then rendered in the default graphics-context fill color, which is BLACK.

  • Light mode: black chevron on light header background → visible
  • Dark mode: black chevron on dark header background → invisible

Fix

Switch to SF Symbols (chevron.up / chevron.down) configured with SymbolConfiguration.paletteColors([.secondaryLabelColor]). SF Symbol palette tinting is appearance-aware, so Light/Dark mode rendering just works.

Renamed the helper from drawTintedIndicator to drawIndicator since it no longer does any tinting (the symbol is pre-tinted via configuration). Function name now matches what it does.

Why this is the cleanest approach

  • SF Symbols are public API — stable across macOS releases
  • SymbolConfiguration.paletteColors tints at the symbol-rendering layer, respecting current NSAppearance automatically
  • No manual NSGraphicsContext save/restore + .sourceIn blending hacks
  • Multi-sort rendering unchanged (priority number drawn next to chevron via separate text path)

Test plan

  • Light mode: click column header → chevron visible
  • Dark mode: click column header → chevron visible (was missing before this fix)
  • Toggle Light ↔ Dark mid-session: chevron tint updates
  • Multi-sort: shift-click second column → both columns show chevrons, secondary has priority number "2" / "3" alongside
  • `xcodebuild build` clean
  • `swiftlint lint --strict` 0 violations

@datlechin datlechin merged commit ce6dae3 into main Apr 29, 2026
2 checks passed
@datlechin datlechin deleted the fix/sort-chevron-sf-symbol branch April 29, 2026 20:10
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.

1 participant