Skip to content

Commit c3f6d90

Browse files
authored
Merge branch 'master' into support-disable-table-radio
2 parents 42d4655 + 8ccf0aa commit c3f6d90

8 files changed

+46
-12
lines changed

package-lock.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/popover/popover.directive.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {
2+
ChangeDetectorRef,
23
Directive,
34
EventEmitter,
45
HostBinding,
@@ -95,6 +96,8 @@ export class PopoverContainer {
9596
"left" | "left-bottom" | "left-top" |
9697
"right" | "right-bottom" | "right-top" = "bottom";
9798

99+
constructor(private changeDetectorRef: ChangeDetectorRef) {}
100+
98101
handleChange(open: boolean, event: Event) {
99102
if (this.isOpen !== open) {
100103
this.isOpenChange.emit(open);
@@ -106,5 +109,6 @@ export class PopoverContainer {
106109
this.onClose.emit(event);
107110
}
108111
this.isOpen = open;
112+
this.changeDetectorRef.markForCheck();
109113
}
110114
}

src/toggletip/toggletip.component.spec.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,11 @@ describe("Toggletip", () => {
102102
fixture.detectChanges();
103103
expect(toggletipEl.componentInstance.isOpen).toBeFalsy();
104104
}));
105+
106+
it("should markForCheck given the changeDetectorRef is set", () => {
107+
const spy = spyOn(toggletipEl.componentInstance.ref, "markForCheck");
108+
buttonEl.nativeElement.click();
109+
fixture.detectChanges();
110+
expect(spy).toHaveBeenCalled();
111+
});
105112
});

src/toggletip/toggletip.component.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import {
22
AfterViewInit,
3+
ChangeDetectionStrategy,
4+
ChangeDetectorRef,
35
Component,
46
ContentChild,
57
ElementRef,
@@ -23,6 +25,7 @@ import { ToggletipButton } from "./toggletip-button.directive";
2325
*/
2426
@Component({
2527
selector: "cds-toggletip, ibm-toggletip",
28+
changeDetection: ChangeDetectionStrategy.OnPush,
2629
template: `
2730
<ng-content select="[cdsToggletipButton]"></ng-content>
2831
<cds-popover-content>
@@ -42,8 +45,8 @@ export class Toggletip extends PopoverContainer implements AfterViewInit {
4245

4346
documentClick = this.handleFocusOut.bind(this);
4447

45-
constructor(private hostElement: ElementRef, private renderer: Renderer2) {
46-
super();
48+
constructor(private hostElement: ElementRef, private renderer: Renderer2, private ref: ChangeDetectorRef) {
49+
super(ref);
4750
this.highContrast = true;
4851
this.dropShadow = false;
4952
}

src/tooltip/definition-tooltip.component.spec.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,11 @@ describe("Definition tooltip", () => {
5151
fixture.detectChanges();
5252
expect(tooltipEl.componentInstance.isOpenChange.emit).toHaveBeenCalled();
5353
});
54+
55+
it("should markForCheck given the changeDetectorRef is set", () => {
56+
const spy = spyOn(tooltipEl.componentInstance.ref, "markForCheck");
57+
buttonEl.triggerEventHandler("click", null);
58+
fixture.detectChanges();
59+
expect(spy).toHaveBeenCalled();
60+
});
5461
});

src/tooltip/definition-tooptip.component.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import {
2+
ChangeDetectionStrategy,
3+
ChangeDetectorRef,
24
Component,
35
HostListener,
46
Input,
@@ -17,6 +19,7 @@ import { PopoverContainer } from "carbon-components-angular/popover";
1719
*/
1820
@Component({
1921
selector: "cds-tooltip-definition, ibm-tooltip-definition",
22+
changeDetection: ChangeDetectionStrategy.OnPush,
2023
template: `
2124
<button
2225
class="cds--definition-term"
@@ -57,8 +60,8 @@ export class TooltipDefinition extends PopoverContainer {
5760
*/
5861
@Input() description: string | TemplateRef<any>;
5962

60-
constructor() {
61-
super();
63+
constructor(private ref: ChangeDetectorRef) {
64+
super(ref);
6265
this.highContrast = true;
6366
this.dropShadow = false;
6467
}

src/tooltip/tooltip.component.spec.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,11 @@ describe("Tooltip", () => {
6868
expect(tooltipEl.componentInstance.isOpenChange.emit).toHaveBeenCalled();
6969
expect(tooltipEl.componentInstance.isOpen).toBeFalsy();
7070
});
71+
72+
it("should markForCheck given the changeDetectorRef is set", () => {
73+
const spy = spyOn(tooltipEl.componentInstance.ref, "markForCheck");
74+
tooltipEl.nativeElement.dispatchEvent(new Event("focusin"));
75+
fixture.detectChanges();
76+
expect(spy).toHaveBeenCalled();
77+
});
7178
});

src/tooltip/tooltip.component.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import {
22
AfterContentChecked,
3+
ChangeDetectionStrategy,
4+
ChangeDetectorRef,
35
Component,
46
ElementRef,
57
HostBinding,
@@ -21,6 +23,7 @@ import { PopoverContainer } from "carbon-components-angular/popover";
2123
*/
2224
@Component({
2325
selector: "cds-tooltip, ibm-tooltip",
26+
changeDetection: ChangeDetectionStrategy.OnPush,
2427
template: `
2528
<span #contentWrapper>
2629
<ng-content></ng-content>
@@ -66,8 +69,8 @@ export class Tooltip extends PopoverContainer implements AfterContentChecked {
6669

6770
@ViewChild("contentWrapper") wrapper: ElementRef<HTMLSpanElement>;
6871

69-
constructor() {
70-
super();
72+
constructor(private ref: ChangeDetectorRef) {
73+
super(ref);
7174
this.highContrast = true;
7275
this.dropShadow = false;
7376
}

0 commit comments

Comments
 (0)