Skip to content

jph-FLOR-1962 Add auto overflow tooltip for menu items#11

Open
jph-bsw wants to merge 1 commit intomainfrom
jph-FLOR-1962-menu-items-tooltips
Open

jph-FLOR-1962 Add auto overflow tooltip for menu items#11
jph-bsw wants to merge 1 commit intomainfrom
jph-FLOR-1962-menu-items-tooltips

Conversation

@jph-bsw
Copy link
Copy Markdown
Member

@jph-bsw jph-bsw commented Mar 16, 2026

Introduce automatic overflow tooltips for .blue-menu-item: add src/js/menu-item-tooltip.ts (ResizeObserver/MutationObserver based) which sets data-tooltip/title and toggles blue-tooltip-end on truncated labels, and exposes init/update/destroy on window.blueWeb.menuItemOverflowTooltips. Import the new script in site layout. Add CSS rule to display tooltip-enabled menu items inline-flex. Update docs and examples (site public llms.txt, search-index.json, and Menu Item.mdx) to show the overflow tooltip, adjust various example class names (BLUE- → blue-), and add several UI/docs snippets (Header, .blue-label, utilities, intro changes).

Introduce automatic overflow tooltips for .blue-menu-item: add src/js/menu-item-tooltip.ts (ResizeObserver/MutationObserver based) which sets data-tooltip/title and toggles blue-tooltip-end on truncated labels, and exposes init/update/destroy on window.blueWeb.menuItemOverflowTooltips. Import the new script in site layout. Add CSS rule to display tooltip-enabled menu items inline-flex. Update docs and examples (site public llms.txt, search-index.json, and Menu Item.mdx) to show the overflow tooltip, adjust various example class names (BLUE- → blue-), and add several UI/docs snippets (Header, .blue-label, utilities, intro changes).
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds automatic “overflow-only” tooltips to .blue-menu-item labels, wiring it into the docs site so truncated menu items get a tooltip without manual markup.

Changes:

  • Introduces menu-item-tooltip.ts (ResizeObserver/MutationObserver-driven) to auto-set data-tooltip and tooltip positioning class when labels are truncated.
  • Loads the new script from the docs site layout to activate the behavior globally.
  • Updates styling/docs assets to support and demonstrate the new tooltip behavior.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/js/menu-item-tooltip.ts New runtime that detects truncated menu labels and applies/removes tooltip attributes/classes; exposes init/update/destroy on window.blueWeb.
site/src/layouts/Layout.astro Imports the new tooltip script so it runs on the documentation site.
dist/styles/_menu-item.scss Ensures tooltip-enabled menu items keep inline-flex layout even when tooltip classes apply inline-block.
site/public/llms.txt Documentation/examples updated to reflect new/renamed classes and show tooltip behavior.
site/public/search-index.json Updates docs search index entries to match the new/updated docs pages.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +117 to +120
mutationObserver = new MutationObserver(() => scheduleUpdateAll())
if (document.body) {
mutationObserver.observe(document.body, { childList: true, subtree: true, characterData: true })
}
Comment on lines +138 to +152
export function destroyMenuItemOverflowTooltips() {
resizeObserver?.disconnect()
mutationObserver?.disconnect()

if (resizeHandler) {
window.removeEventListener("resize", resizeHandler)
}

resizeObserver = null
mutationObserver = null
resizeHandler = null
observedLabels = new WeakSet<HTMLElement>()
initialized = false
started = false
}
Comment on lines +123 to +131
export function initMenuItemOverflowTooltips() {
if (initialized) return
initialized = true

if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", start, { once: true })
} else {
start()
}
Comment on lines +55 to +58
if (resizeObserver && !observedLabels.has(labelElement)) {
resizeObserver.observe(labelElement)
observedLabels.add(labelElement)
}
Comment on lines +60 to +68
const hasManualTooltip =
(menuItem.hasAttribute(TOOLTIP_ATTR) && menuItem.getAttribute(AUTO_TOOLTIP_ATTR) !== "true") ||
(menuItem.hasAttribute("title") && menuItem.getAttribute(AUTO_TOOLTIP_ATTR) !== "true")

if (hasManualTooltip) {
return
}

const text = getTooltipText(labelElement)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Statt, dass das Script speziell auf .blue-menu-item abgestimmt ist, sollte es besser ein allgemeiner Detector als Funktion dafür sein, ob Overflow auf einem Element vorhanden ist. So kann er auch für andere Stellen verwendet werden und auch andere Dinge als nur Tooltip über "blue-tooltip-*" zu setzen.
In Blue React und Blue Blazor kann dann in der MenuItem-Komponente diese Funktion verwendet werden und mit der jeweils empfohlenden Art ein Tooltip erstellt werden.

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.

3 participants