Skip to content

Commit

Permalink
only show tooltip if the normal text doesnt fit
Browse files Browse the repository at this point in the history
  • Loading branch information
wouter-willems committed May 28, 2024
1 parent 567e3d0 commit 59e0e32
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion projects/demo/src/app/demo/demo.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
</div>
</div>

<div class="smallText" klpWithTooltip="orange">I am a small bit of text</div>
<div class="smallText" klpWithTooltip="black">I am a small bit of text</div>

<div>
<klp-form-element caption="radioButtons classic" spaceDistribution="34-66" verticalAlignment="top">
Expand Down
2 changes: 1 addition & 1 deletion projects/klippa/ngx-enhancy-forms/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@klippa/ngx-enhancy-forms",
"version": "14.19.0",
"version": "14.19.1",
"publishConfig": {
"access": "public"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ export class WithTooltipDirective {
if (!stringIsSetAndFilled(this.klpWithTooltip)) {
return;
}
if (el.nativeElement.innerText.trim().length < 1) {
return;
}
console.log(el.nativeElement.offsetWidth, el.nativeElement.scrollWidth);
if (el.nativeElement.offsetWidth >= el.nativeElement.scrollWidth) {
return;
}
if (getComputedStyle(el.nativeElement).position === 'static') {
el.nativeElement.style.position = 'relative';
}
Expand Down

0 comments on commit 59e0e32

Please sign in to comment.