Skip to content

Conversation

@RisingOrange
Copy link
Contributor

@RisingOrange RisingOrange commented Jan 10, 2026

Summary

Adds a tag display mode toggle to the note editor that allows switching between auto and full-tag views.

Auto mode (default): Current behavior - shortens hierarchical tags (e.g., ...::subtopic) when there are more than 2 rows of tags.

image

Full mode: Shows complete tag names with middle truncation for long tags, one tag per row, with a maximum height of 50vh and vertical scrolling.

image

Motivation

Users working with many hierarchical tags struggle with the current auto-shortening behavior that truncates tags to ...::subtag. They have to hover over each tag individually to see the full path, which is tedious and straining.

AnKing deck maintainers, who often work with notes that have ~10 long tags, described it as "losing their eyesight" hovering over tags one by one. I made an add-on implementing similar functionality and they liked it a lot.

This was also requested on the forum. The toggle allows users who need full visibility to enable it, while preserving the compact default for those with fewer/shorter tags.

I can release this as an add-on if it doesn't fit upstream, but wanted to see what you think about adding it to Anki first.

Features

  • Toggle button in tag editor (next to the + button) with view_compact / view_list icons
  • Keyboard shortcut: Ctrl+.
  • Smart middle truncation that adapts to editor width (e.g., very-long-tag-namevery-...name)
  • Setting persists via collection config (tagDisplayFull)
  • Tooltip shows current action and shortcut

Technical Details

Middle Truncation

  • Uses canvas-based text measurement to avoid DOM thrashing
  • Binary search to find optimal truncation point
  • Responsive to editor width changes via ResizeObserver with 32ms debounce

Layout Stability

  • Consistent row heights using calc(var(--font-size, 15px) * 1.5 + 2px)
  • Spacer collapses only when adding new tag at the end (tracked by tag ID)
  • Empty tags auto-deleted when navigating away
  • Toggle button uses mousedown|preventDefault to prevent input blur

Mode Switch Handling

  • When switching from full mode back to auto mode, tags are re-measured after browser layout completes
  • Uses double requestAnimationFrame to ensure CSS changes are applied before measuring
  • Sequence counter cancels stale async operations if user switches modes rapidly

Screenshots and video

Button tooltips

image image

Video

2026-01-10.14-28-15.mp4

Test Plan

  • Add note with hierarchical tags (e.g., subject::topic::subtopic)
  • Verify toggle button appears next to "Add tag" button
  • Click toggle to switch between Auto and Full modes
  • Verify Ctrl+. keyboard shortcut works
  • Test with many tags (20+): verify Full mode has scroll
  • Test long tags: verify middle truncation works
  • Close and reopen editor: verify setting persists
  • Edit existing tag in full mode: verify spacer doesn't collapse
  • Add new tag in full mode: verify spacer collapses appropriately
  • Switch auto → full → auto with few tags: verify tags are NOT shortened incorrectly
  • Switch auto → full → auto with many tags (>2 rows): verify tags ARE shortened correctly

🤖 Generated with Claude Code

RisingOrange and others added 10 commits January 8, 2026 23:04
Adds an eye icon button in the tag editor that toggles between:
- Auto mode: current behavior, shortens tags when >2 rows
- Full mode: shows complete tag names, one per row, max 50vh with scroll

Features:
- Middle truncation for long tags that adapts to editor width
- Keyboard shortcut: Ctrl+.
- Setting persists via collection config

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add mousedown preventDefault on toggle button to prevent input blur
- Add end-0 to TagInput for proper width in full mode
- Add consistent min-height for tag rows and spacer using font-size calc
- Hide spacer when editing to prevent layout shift

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Extract tagDisplayModeShortcut constant to single source of truth
- Pass shortcut to TagDisplayModeButton for tooltip display
- Rename PADDING_PX to RIGHT_PADDING_PX with detailed comment
- Add overflow-x: hidden to prevent horizontal scrollbar in full mode

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Track new tag by ID (newTagId) instead of boolean flag for robustness
- Spacer only collapses when adding new tag at end, not when editing existing
- Auto-delete empty tags when navigating away (blur handler handles deletion)
- Prevent creating duplicate empty tags when pressing Enter on empty field
- Simplify logic: set newTagId in appendTagAndFocusAt, clear in on:tagedit

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When switching from full mode back to auto mode, tags were incorrectly
shortened because the layout measurement happened before the browser
completed CSS layout changes. Now we wait for the browser to finish
layout (using double requestAnimationFrame) before measuring row count.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@RisingOrange RisingOrange marked this pull request as ready for review January 13, 2026 11:48
Copy link
Collaborator

@abdnh abdnh left a comment

Choose a reason for hiding this comment

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

This is working very well. The tooltip/ellipsis check looks complicated; I've not found any issues with it, though. I think it would be nice to make the tags field resizable, but that's maybe better left for another time.

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