Skip to content

Commit 9062679

Browse files
committed
Merge branch 'master' of https://github.com/IgniteUI/igniteui-angular into rivanova/tooltip-show-hide-triggers
2 parents 01608e9 + 7d3201e commit 9062679

File tree

4 files changed

+59
-4
lines changed

4 files changed

+59
-4
lines changed

projects/igniteui-angular/src/lib/core/styles/components/tooltip/_tooltip-theme.scss

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
gap: rem(8px);
2424
min-height: rem(24px);
2525
min-width: rem(24px);
26-
max-width: 200px;
26+
max-width: rem(200px);
2727
width: fit-content;
2828

2929
igx-icon {
@@ -34,6 +34,10 @@
3434
display: flex;
3535
cursor: default;
3636
}
37+
38+
&:not([data-default]) {
39+
max-width: initial;
40+
}
3741
}
3842

3943
%arrow--top {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<span igxTooltip>{{content}}</span>
1+
<span data-default igxTooltip>{{content}}</span>

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

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { DebugElement } from '@angular/core';
22
import { fakeAsync, TestBed, tick, flush, waitForAsync, ComponentFixture } from '@angular/core/testing';
33
import { By } from '@angular/platform-browser';
44
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
5-
import { IgxTooltipSingleTargetComponent, IgxTooltipMultipleTargetsComponent, IgxTooltipPlainStringComponent, IgxTooltipWithToggleActionComponent, IgxTooltipWithCloseButtonComponent } from '../../test-utils/tooltip-components.spec';
5+
import { IgxTooltipSingleTargetComponent, IgxTooltipMultipleTargetsComponent, IgxTooltipPlainStringComponent, IgxTooltipWithToggleActionComponent, IgxTooltipWithCloseButtonComponent, IgxTooltipWithNestedContentComponent } from '../../test-utils/tooltip-components.spec';
66
import { UIInteractions } from '../../test-utils/ui-interactions.spec';
77
import { HorizontalAlignment, VerticalAlignment, AutoPositionStrategy } from '../../services/public_api';
88
import { IgxTooltipDirective } from './tooltip.directive';
@@ -30,7 +30,8 @@ describe('IgxTooltip', () => {
3030
IgxTooltipMultipleTargetsComponent,
3131
IgxTooltipPlainStringComponent,
3232
IgxTooltipWithToggleActionComponent,
33-
IgxTooltipWithCloseButtonComponent
33+
IgxTooltipWithCloseButtonComponent,
34+
IgxTooltipWithNestedContentComponent
3435
]
3536
}).compileComponents();
3637
UIInteractions.clearOverlay();
@@ -546,6 +547,36 @@ describe('IgxTooltip', () => {
546547

547548
verifyTooltipVisibility(tooltipNativeElement, tooltipTarget, false);
548549
}));
550+
551+
it('Should respect default max-width constraint for plain string tooltip', fakeAsync(() => {
552+
hoverElement(button);
553+
flush();
554+
555+
verifyTooltipVisibility(tooltipNativeElement, tooltipTarget, true);
556+
557+
const maxWidth = getComputedStyle(tooltipNativeElement).maxWidth;
558+
expect(maxWidth).toBe('200px');
559+
}));
560+
});
561+
562+
describe('Custom content tooltip', () => {
563+
beforeEach(waitForAsync(() => {
564+
fix = TestBed.createComponent(IgxTooltipWithNestedContentComponent);
565+
fix.detectChanges();
566+
button = fix.debugElement.query(By.directive(IgxTooltipTargetDirective));
567+
tooltipTarget = fix.componentInstance.tooltipTarget;
568+
tooltipNativeElement = fix.debugElement.query(By.directive(IgxTooltipDirective)).nativeElement;
569+
}));
570+
571+
it('Should not have max-width constraint for custom content tooltip', fakeAsync(() => {
572+
hoverElement(button);
573+
flush();
574+
575+
verifyTooltipVisibility(tooltipNativeElement, tooltipTarget, true);
576+
577+
const maxWidth = getComputedStyle(tooltipNativeElement).maxWidth;
578+
expect(maxWidth).toBe('none');
579+
}));
549580
});
550581

551582
describe('Multiple targets with single tooltip', () => {

projects/igniteui-angular/src/lib/test-utils/tooltip-components.spec.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,3 +149,23 @@ export class IgxTooltipWithCloseButtonComponent {
149149
@ViewChild(IgxTooltipDirective, { static: true }) public tooltip: IgxTooltipDirective;
150150
@ViewChild(IgxTooltipTargetDirective, { static: true }) public tooltipTarget: IgxTooltipTargetDirective;
151151
}
152+
153+
@Component({
154+
template: `
155+
<button class="btn" [igxTooltipTarget]="tooltipRef">
156+
Hover me
157+
</button>
158+
159+
<div igxTooltip #tooltipRef="tooltip">
160+
<div class="nested" style="background: red; width: 400px; color: white; padding: 4px;">
161+
<span>Nested content</span>
162+
</div>
163+
</div>
164+
`,
165+
imports: [IgxTooltipDirective, IgxTooltipTargetDirective],
166+
standalone: true
167+
})
168+
export class IgxTooltipWithNestedContentComponent {
169+
@ViewChild(IgxTooltipDirective, { static: true }) public tooltip!: IgxTooltipDirective;
170+
@ViewChild(IgxTooltipTargetDirective, { static: true }) public tooltipTarget!: IgxTooltipTargetDirective;
171+
}

0 commit comments

Comments
 (0)