Skip to content

Commit 1a7d51a

Browse files
committed
fix(tooltip): placement to bottom, no arrow by default, arrow multi targets
1 parent 4867e8a commit 1a7d51a

File tree

2 files changed

+32
-30
lines changed

2 files changed

+32
-30
lines changed

projects/igniteui-angular/src/lib/directives/tooltip/tooltip-target.directive.ts

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export class IgxTooltipTargetDirective extends IgxToggleActionDirective implemen
8585

8686

8787
/**
88-
* Where to place the tooltip relative to the target element. Default value is `top`.
88+
* Where to place the tooltip relative to the target element. Default value is `bottom`.
8989
* ```html
9090
* <igx-icon [igxTooltipTarget]="tooltipRef" placement="bottom-start">info</igx-icon>
9191
* <span #tooltipRef="tooltip" igxTooltip>Hello there, I am a tooltip!</span>
@@ -124,29 +124,29 @@ export class IgxTooltipTargetDirective extends IgxToggleActionDirective implemen
124124
*
125125
* ```typescript
126126
* // get
127-
* let isArrowDisabled = this.tooltip.disableArrow;
127+
* let isArrowDisabled = this.tooltip.hasArrow;
128128
* ```
129129
*
130130
* ```typescript
131131
* // set
132-
* this.tooltip.disableArrow = false;
132+
* this.tooltip.hasArrow = false;
133133
* ```
134134
*
135135
* ```html
136136
* <!--set-->
137-
* <igx-icon igxTooltipTarget [disableArrow]="true" [tooltip]="'Infragistics Inc. HQ'">info</igx-icon>
137+
* <igx-icon igxTooltipTarget [hasArrow]="true" [tooltip]="'Infragistics Inc. HQ'">info</igx-icon>
138138
* ```
139139
*/
140140
@Input()
141-
public set disableArrow(value: boolean) {
141+
public set hasArrow(value: boolean) {
142142
if (this.target) {
143-
this.target.arrow.style.display = value ? 'none' : '';
143+
this.target.arrow.style.display = value ? '' : 'none';
144144
}
145-
this._disableArrow = value;
145+
this._hasArrow = value;
146146
}
147147

148-
public get disableArrow(): boolean {
149-
return this._disableArrow;
148+
public get hasArrow(): boolean {
149+
return this._hasArrow;
150150
}
151151

152152
/**
@@ -327,9 +327,9 @@ export class IgxTooltipTargetDirective extends IgxToggleActionDirective implemen
327327
private _destroy$ = new Subject<void>();
328328
private _autoHideDelay = 180;
329329
private _isForceClosed = false;
330-
private _disableArrow = false;
330+
private _hasArrow = false;
331331
private _offset = 6;
332-
private _placement: TooltipPlacement = TooltipPlacement.top;
332+
private _placement: TooltipPlacement = TooltipPlacement.bottom;
333333
private _closeButtonRef?: ComponentRef<IgxTooltipCloseButtonComponent>;
334334
private _closeTemplate: TemplateRef<any>;
335335
private _sticky = false;
@@ -419,8 +419,8 @@ export class IgxTooltipTargetDirective extends IgxToggleActionDirective implemen
419419
* @hidden
420420
*/
421421
public ngOnChanges(changes: SimpleChanges): void {
422-
if (changes['disableArrow']) {
423-
this.target.arrow.style.display = changes['disableArrow'].currentValue ? 'none' : '';
422+
if (changes['hasArrow']) {
423+
this.target.arrow.style.display = changes['hasArrow'].currentValue ? '' : 'none';
424424
}
425425
}
426426

@@ -570,9 +570,11 @@ export class IgxTooltipTargetDirective extends IgxToggleActionDirective implemen
570570
*/
571571
private _checkTooltipForMultipleTargets(): void {
572572
if (!this.target.tooltipTarget) {
573+
this.hasArrow = this._hasArrow;
573574
this.target.tooltipTarget = this;
574575
}
575576
if (this.target.tooltipTarget !== this) {
577+
this.hasArrow = this._hasArrow;
576578
if (this.target.tooltipTarget.sticky) {
577579
this.target.tooltipTarget._removeCloseButtonFromTooltip();
578580
}

projects/igniteui-angular/src/lib/directives/tooltip/tooltip.directive.spec.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -88,38 +88,38 @@ describe('IgxTooltip', () => {
8888
verifyTooltipVisibility(tooltipNativeElement, tooltipTarget, false);
8989
}));
9090

91-
it('should render a default arrow', fakeAsync(() => {
92-
expect(tooltipTarget.disableArrow).toBeFalse();
91+
it('should not render a default arrow', fakeAsync(() => {
92+
expect(tooltipTarget.hasArrow).toBeFalse();
9393

9494
hoverElement(button);
9595
flush();
9696

9797
verifyTooltipVisibility(tooltipNativeElement, tooltipTarget, true);
9898

99-
const arrow = tooltipNativeElement.querySelector('.igx-tooltip--top');
99+
const arrow = tooltipNativeElement.querySelector('.igx-tooltip--bottom');
100100
expect(arrow).not.toBeNull();
101+
expect(arrow.style.display).toEqual("none");
101102
}));
102103

103-
it('should show/hide the arrow via the `disableArrow` property', fakeAsync(() => {
104-
expect(tooltipTarget.disableArrow).toBeFalse();
105-
expect(tooltipNativeElement.querySelector('.igx-tooltip--top')).toBeNull();
104+
it('should show/hide the arrow via the `hasArrow` property', fakeAsync(() => {
105+
expect(tooltipTarget.hasArrow).toBeFalse();
106+
expect(tooltipNativeElement.querySelector('.igx-tooltip--bottom')).toBeNull();
106107

107-
tooltipTarget.disableArrow = true;
108+
tooltipTarget.hasArrow = true;
108109
fix.detectChanges();
109110

110111
hoverElement(button);
111112
flush();
112113

113114
verifyTooltipVisibility(tooltipNativeElement, tooltipTarget, true);
114115

115-
expect(tooltipTarget.disableArrow).toBeTrue();
116-
const arrow = tooltipNativeElement.querySelector('.igx-tooltip--top');
117-
expect(arrow.style.display).toEqual("none");
116+
expect(tooltipTarget.hasArrow).toBeTrue();
117+
const arrow = tooltipNativeElement.querySelector('.igx-tooltip--bottom');
118+
expect(arrow.style.display).toEqual("");
118119

119-
tooltipTarget.disableArrow = false;
120+
tooltipTarget.hasArrow = false;
120121
fix.detectChanges();
121-
expect(arrow.style.display).toEqual("");
122-
expect(arrow.style.left).toEqual("75px");
122+
expect(arrow.style.display).toEqual("none");
123123
}));
124124

125125
it('show target tooltip when hovering its target and ignore [tooltip] input', fakeAsync(() => {
@@ -700,14 +700,14 @@ describe('IgxTooltip', () => {
700700
}));
701701

702702
it('should correctly manage arrow state between different targets', fakeAsync(() => {
703-
targetOne.disableArrow = true;
703+
targetOne.hasArrow = true;
704704
fix.detectChanges();
705705

706706
hoverElement(buttonOne);
707707
flush();
708708

709709
verifyTooltipVisibility(tooltipNativeElement, targetOne, true);
710-
expect(tooltipNativeElement.querySelector('.igx-tooltip--top').style.display).toEqual('none');
710+
expect(tooltipNativeElement.querySelector('.igx-tooltip--bottom').style.display).toEqual('');
711711

712712
unhoverElement(buttonOne);
713713
flush();
@@ -716,7 +716,7 @@ describe('IgxTooltip', () => {
716716
flush();
717717

718718
verifyTooltipVisibility(tooltipNativeElement, targetTwo, true);
719-
expect(tooltipNativeElement.querySelector('.igx-tooltip--top').style.display).toEqual('');
719+
expect(tooltipNativeElement.querySelector('.igx-tooltip--bottom').style.display).toEqual('none');
720720
}));
721721
});
722722

@@ -938,7 +938,7 @@ export const verifyTooltipPosition = (
938938
tooltipNativeElement: HTMLElement,
939939
actualTarget: { nativeElement: HTMLElement },
940940
shouldAlign:boolean = true,
941-
placement: TooltipPlacement = 'top',
941+
placement: TooltipPlacement = 'bottom',
942942
offset: number = 6
943943
) => {
944944
const tooltip = tooltipNativeElement.getBoundingClientRect();

0 commit comments

Comments
 (0)