Skip to content

Replace hardcoded toolbar breakpoints with KListWithOverflow#5707

Open
nucleogenesis wants to merge 1 commit intolearningequality:unstablefrom
nucleogenesis:5258-rte--dynamic-width
Open

Replace hardcoded toolbar breakpoints with KListWithOverflow#5707
nucleogenesis wants to merge 1 commit intolearningequality:unstablefrom
nucleogenesis:5258-rte--dynamic-width

Conversation

@nucleogenesis
Copy link
Member

🤖 AI Disclaimer: Most code changes performed by Claude Code at my guidance. I have personally verified the changes and performed the "testing plan" described below

Summary

Replace hardcoded pixel breakpoints in the RTE toolbar with dynamic KListWithOverflow from KDS. This allows the toolbar to automatically collapse items into a "More" dropdown based on available space, rather than using fixed breakpoints.

Changes:

  • Integrated KListWithOverflow component to dynamically measure and collapse toolbar items
  • Added "More" dropdown menu that shows overflow items with full labels
  • Added CSS fix (overflow: hidden on .list) to prevent flicker during resize recalculation

Closes: #5258

Screenshots

Viewport Description Screenshot
1280px Full width - all toolbar items visible toolbar_full_1280px
900px Mid width - all toolbar items visible toolbar_medium_900px
700px Narrow - items collapse, "More" button appears toolbar_narrow_700px
500px Mobile - most items in overflow menu toolbar_mobile_500px
500px Mobile with "More" dropdown open toolbar_mobile_500px_dropdown

Test Plan

  • Verify toolbar displays all items at wide viewports (1200px+)
  • Verify "More" button appears when viewport narrows
  • Verify clicking "More" shows dropdown with overflow items
  • Verify no flicker/flash when resizing viewport
  • Verify overflow items in dropdown are functional (bold, italic, etc.)
  • Verify keyboard navigation works in overflow menu (Arrow keys, Escape)
  • Test in RTL mode

Use KDS KListWithOverflow component to dynamically collapse toolbar
items into a "More" dropdown based on available space instead of
fixed pixel breakpoints.

- Integrate KListWithOverflow for automatic overflow detection
- Add overflow hidden CSS to prevent flicker during resize
- Simplify toolbar logic by removing manual breakpoint calculations

Fixes learningequality#5258

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy link

@rtibblesbot rtibblesbot left a comment

Choose a reason for hiding this comment

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

Clean replacement of hardcoded toolbar breakpoints with KListWithOverflow. The approach is solid — delegating overflow measurement to KDS removes brittle pixel breakpoints and makes the toolbar resilient to future button additions.

CI passing. Screenshots verified across viewports — toolbar collapses gracefully and the overflow dropdown renders correctly.

  • suggestion: ::v-deep .list targets KDS internals (line 524) — could break on KDS updates. Worth a comment noting the dependency.
  • suggestion: Three aria-label strings are hardcoded in English rather than using the i18n system. Pre-existing from the previous implementation, but worth addressing as a follow-up.
  • praise: The isFromOverflow check via moreDropdown.value?.contains(event.target) (line 403) is a nice improvement — it directly detects overflow context instead of using the old proxy check on visibleCategories.

}

/* Clip items that wrap during resize recalculation to prevent flicker */
.overflow-list ::v-deep .list {

Choose a reason for hiding this comment

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

suggestion: This ::v-deep .list selector reaches into KDS internals to prevent flicker. It works, but it's fragile — if KDS changes the class name or structure in a future version, this breaks silently. Consider adding a brief comment noting which KDS version/component this targets, so future updates can verify it still applies.

ref="moreDropdownContainer"
class="more-dropdown-container"
role="group"
:aria-label="'More options'"

Choose a reason for hiding this comment

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

suggestion: 'More options' and 'Additional formatting options' (line 179) are hardcoded English strings. These were carried over from the previous implementation, but since this PR is already touching this area, it would be a good opportunity to add them to TipTapEditorStrings.js for proper i18n. Not blocking since it's pre-existing.

// If the tool is in the overflow menu, we center the modal
if (!visibleCategories.value.includes('insert')) target = null;
// If the tool is in the overflow menu (clicked from dropdown), center the modal
const isFromOverflow = moreDropdown.value?.contains(event.target);

Choose a reason for hiding this comment

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

praise: Good improvement — directly checking moreDropdown.value?.contains(event.target) is more robust than the old proxy check on visibleCategories. This correctly handles the case regardless of which specific groups are overflowed.

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