Skip to content

refactor: extract tooltip integration into reusable decorator (#9938) - #10343

Open
deleonio wants to merge 3 commits into
developfrom
claude/elegant-pasteur-BiOmK
Open

refactor: extract tooltip integration into reusable decorator (#9938)#10343
deleonio wants to merge 3 commits into
developfrom
claude/elegant-pasteur-BiOmK

Conversation

@deleonio

@deleonio deleonio commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Closes #9938

Problem

Since #9605 the tooltip is wired directly into each component. The same boilerplate (controller instantiation, watchLabel/watchAlign, componentWillLoad/componentDidRender/disconnectedCallback lifecycle, hideTooltip on click, and the <TooltipFC> rendering) is duplicated across kol-abbr, kol-button-wc and kol-link-wc.

Change

  • New TooltipDecorator (internal/functional-components/tooltip/decorator.tsx): a composable helper that encapsulates the TooltipController lifecycle and the tooltip rendering. Components compose it via getTrigger (lazy accessor for the anchor element) and an optional wrapperClass.
  • Migrated kol-abbr, kol-button-wc and kol-link-wc to use the decorator instead of re-implementing the wiring. Each component now delegates in single lines (watchLabel, watchAlign, componentWillLoad, componentDidRender, disconnectedCallback, hide, render).
  • Added a focused unit test for the decorator's render guard.

The rendered output is kept byte-identical (Button/Link keep their __tooltip wrapper, Abbr stays wrapper-less), so existing snapshots remain green. No API, dependency or configuration changes; no breaking changes.

Scope / follow-up

This PR deliberately targets only the three web components that hold a stable controller instance. FieldControl/FormField use a per-id Map<string, TooltipController> because their functional component is recreated on every render — unifying that with the decorator is left as a follow-up to keep this diff small and review-friendly.

Manual verification

The tooltip behavior is demonstrable in the sample app via the existing _hideLabel examples for Button, Link and Abbr (the tooltip appears on hover/focus when the label is hidden).

⚠️ Quality gates (typecheck/lint/unit/build) could not be executed in this environment because node_modules is not installed (MCP environment). A manual diff review was performed instead; pnpm format could not be run.

This PR addresses a contributor-reported issue.


Generated by Claude Code

…ator (#9938)

Introduce a composable TooltipDecorator that encapsulates the
TooltipController lifecycle (init, listener sync, teardown) and the
tooltip rendering. Migrate kol-abbr, kol-button-wc and kol-link-wc to
compose it instead of re-implementing the wiring in every component.

The rendered output is kept byte-identical, so existing snapshots stay
green. No API, dependency or configuration changes.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new TooltipDecorator class to encapsulate the tooltip controller lifecycle and rendering logic, simplifying the integration of tooltips across components like KolAbbr, KolButtonWc, and KolLinkWc. Unit tests for the decorator are also added. Feedback suggests removing a redundant clsx call and its unused import in the TooltipDecorator implementation.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread packages/components/src/internal/functional-components/tooltip/decorator.tsx Outdated
Comment thread packages/components/src/internal/functional-components/tooltip/decorator.tsx Outdated
@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

🚀 MCP preview deployed to Vercel: https://kolibri-m4l56jso1-public-ui-kolibri-mcp.vercel.app

@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

🚀 Preview deployed to GitHub Pages: https://public-ui.github.io/kolibri/pr-10343/91031c5/
Commit: 91031c5

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors tooltip wiring in @public-ui/components by extracting the repeated TooltipController lifecycle + rendering integration into a reusable TooltipDecorator, then migrating kol-abbr, kol-button-wc, and kol-link-wc to compose that decorator instead of duplicating the same boilerplate.

Changes:

  • Added TooltipDecorator to encapsulate tooltip controller lifecycle hooks, watchers, hide behavior, and tooltip VNode rendering.
  • Updated kol-abbr, kol-button-wc, and kol-link-wc to delegate tooltip behavior to the decorator.
  • Added a focused unit test covering the decorator’s render guard behavior.

Reviewed changes

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

Show a summary per file
File Description
packages/components/src/internal/functional-components/tooltip/test/decorator.spec.ts Adds unit tests for TooltipDecorator.render guard behavior.
packages/components/src/internal/functional-components/tooltip/decorator.tsx Introduces the reusable decorator wrapping TooltipController lifecycle + rendering.
packages/components/src/components/link/component.tsx Replaces inline tooltip wiring/rendering with TooltipDecorator usage for link.
packages/components/src/components/button/component.tsx Replaces inline tooltip wiring/rendering with TooltipDecorator usage for button.
packages/components/src/components/abbr/shadow.tsx Replaces inline tooltip wiring/rendering with TooltipDecorator usage for abbr.

Comment thread packages/components/src/components/link/component.tsx
…9938)

- Drop redundant clsx call/import; pass wrapperClass directly.
- Track the previous trigger in componentDidRender and detach its
  listeners when the anchored element changes or is removed, so the
  reusable decorator cannot leak listeners on trigger changes.
- Make visibility the sole responsibility of the caller: render() now
  guards only on 'visible', so the migrated components reproduce their
  original (byte-identical) markup, including the link hide-label edge
  case.
@deleonio deleonio added Draft release:ignore PR wird vom Release-Changelog ausgeschlossen. and removed Draft labels Jun 8, 2026
@deleonio
deleonio marked this pull request as ready for review June 15, 2026 11:49
Resolve conflict in abbr after its skeleton-architecture migration on
develop: keep the new AbbrController/AbbrFC structure and replace the
manual TooltipController wiring with the reusable TooltipDecorator
(consistent with button and link).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release:ignore PR wird vom Release-Changelog ausgeschlossen.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tooltip-Einbindung in Skeleton-Architektur in Decorator auslagern

3 participants