Skip to content

Commit 9753705

Browse files
authored
Merge pull request #3112 from Akshat55/tooltip-description
fix: reposition tooltip on description reset & change
2 parents b9b5cd3 + f00c68a commit 9753705

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

integration/ng14/angular.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
{
4545
"type": "initial",
4646
"maximumWarning": "500kb",
47-
"maximumError": "1mb"
47+
"maximumError": "1.5mb"
4848
},
4949
{
5050
"type": "anyComponentStyle",

src/tooltip/tooltip.component.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,13 @@ export class Tooltip extends PopoverContainer implements OnChanges, AfterContent
144144
this.handleChange(false);
145145

146146
// Ignore first change since content is not initialized
147-
if ((changes.autoAlign && !changes.autoAlign.firstChange)
148-
|| (changes.disabled && !changes.disabled.firstChange && !changes.disabled.currentValue)) {
147+
if (
148+
(changes.autoAlign && !changes.autoAlign.firstChange)
149+
|| (changes.disabled && !changes.disabled.firstChange && !changes.disabled.currentValue)
150+
// If description is set to empty string when open & autoAlign is true then set to a new value
151+
// positioning of popover is broken because popover content ref/caret no longer exists
152+
|| changes.description
153+
) {
149154
/**
150155
* When `disabled` is `true`, popover content node is removed. So when re-enabling `disabled`,
151156
* we manually update view so querySelector can detect the popover content node.
@@ -155,7 +160,7 @@ export class Tooltip extends PopoverContainer implements OnChanges, AfterContent
155160

156161
// Reset the inline styles
157162
this.popoverContentRef = this.elementRef.nativeElement.querySelector(".cds--popover-content");
158-
this.popoverContentRef.setAttribute("style", "");
163+
this.popoverContentRef?.setAttribute("style", "");
159164
this.caretRef = this.elementRef.nativeElement.querySelector("span.cds--popover-caret");
160165
}
161166

0 commit comments

Comments
 (0)