fix(tree): prevent tooltip for non-truncated option text (#DS-4931) - #1910
fix(tree): prevent tooltip for non-truncated option text (#DS-4931)#1910KamilEmeleev wants to merge 2 commits into
Conversation
|
Visit the preview URL for this PR (updated for commit 482a6d4): https://koobiq-next--prs-1910-ab389bc7.web.app (expires Thu, 27 Aug 2026 12:04:06 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: c9e37e518febda70d0317d07e8ceb35ac43c534c |
There was a problem hiding this comment.
Pull request overview
Fixes incorrect kbq-title tooltip activation for KbqTreeOption when option text is not truncated. The issue came from KbqTitleDirective falling back to measuring the option host element (larger due to padding/checkbox), which made non-truncated text appear “overflown”.
Changes:
- Exposes
textElementonKbqTreeOptionsoKbqTitleDirectivemeasures overflow against the.kbq-option-textclipping container. - Adds unit tests covering “no tooltip when text fits” and “tooltip when text is clipped”.
- Updates the public API snapshot for the Tree component.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tools/public_api_guard/components/tree.api.md | Public API snapshot updated to include KbqTreeOption.textElement. |
| packages/components/tree/tree-selection.component.spec.ts | Adds Jest tests validating overflow detection behavior for kbq-title on tree options. |
| packages/components/tree/tree-option.component.ts | Adds textElement view query to allow KbqTitleDirective to measure the correct clipping element. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
NikGurev
left a comment
There was a problem hiding this comment.
Pointing both parentTextElement and textElement at the same #kbqTitleContainer isn't a mistake — it's parent.offsetWidth < child.scrollWidth degenerating into el.offsetWidth < el.scrollWidth on one element, which is exactly the check needed here.
|
/redeploy-preview |
|
🔄 Redeploying documentation preview. |
lskramarov
left a comment
There was a problem hiding this comment.
Reviewed the fix. The approach is sound and I verified both new tests are genuine regression tests — they fail when textElement is removed and pass with it. prettier, eslint and the API-guard entry are clean.
Eight notes below: 7 inline, plus one that lands in a file outside this diff and so has to live here.
packages/components/title/title.directive.ts:181-184 — the hasEllipsis rationale is now stale
The JSDoc justifies checking both elements like this:
Both elements are checked because
text-overflowis not inherited and consumers place it differently:KbqOption/KbqDropdownItemstyle the measuredchild, whereasKbqTreeOptionstyles theparentcontainer that wraps the child.
KbqTreeOption was the only cited case for the elementHasEllipsis(this.child) || elementHasEllipsis(this.parent) disjunction — and after this PR its parent is its child, so nothing wraps anything. The sentence describes an arrangement that no longer exists, and the || is redundant for the one component it was written for.
AGENTS.md ("Comments"): "Update or remove comments that become outdated because of your changes."
…y and vertical clipping
Summary
Tree options showed a tooltip even when the text was not truncated.
KbqTreeOptionexposed onlyparentTextElement, soKbqTitleDirectivemeasured the.kbq-option-textcontainer against theoption host — which is always bigger, so every option looked overflown.
Reported on
kbq-username, but it is unchanged and correct: plain-text options were affected too.List of notable changes:
textElementso the clipping box is measured against itselfWhat should reviewers focus on?
Content marking its own
#kbqTitleTextkeeps priority, so tree-select and filter-bar should be unaffected.Trade-off: with
parent === childa sub-pixel clip is no longer reported for tree options that do notmark their own
#kbqTitleText. Previously that case reported truncation unconditionally, so it goesfrom always shown to never shown. Content marking its own text keeps both the sub-pixel branch and the
hasEllipsischeck intact.