Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export interface ToggleViewCancelableEventArgs extends ToggleViewEventArgs, Canc
})
export class IgxToggleDirective implements IToggleView, OnInit, OnDestroy {
private elementRef = inject(ElementRef);
private cdr = inject(ChangeDetectorRef);
protected cdr = inject(ChangeDetectorRef);
protected overlayService = inject<IgxOverlayService>(IgxOverlayService);
private navigationService = inject(IgxNavigationService, { optional: true });
private platform = inject(PlatformUtil, { optional: true });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,9 @@ export class IgxTooltipTargetDirective extends IgxToggleActionDirective implemen
this._renderer.appendChild(this.target.element, this._closeButtonRef.location.nativeElement);
this._closeButtonRef.changeDetectorRef.detectChanges();
this.target.role = "status"
// Mark the tooltip directive as Dirty to ensure that
// the CD refreshes the bindings
this.target.cdr?.markForCheck();
Comment thread
mddragnev marked this conversation as resolved.
}
}

Expand All @@ -700,6 +703,9 @@ export class IgxTooltipTargetDirective extends IgxToggleActionDirective implemen
this._renderer.removeChild(this.target.element, this._closeButtonRef.location.nativeElement);
this._closeButtonRef.changeDetectorRef.detectChanges();
this.target.role = "tooltip"
// Mark the tooltip directive as Dirty to ensure that
// the CD refreshes the bindings
this.target.cdr?.markForCheck();
Comment thread
mddragnev marked this conversation as resolved.
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { DebugElement } from '@angular/core';
import { DebugElement, ErrorHandler, provideZonelessChangeDetection } from '@angular/core';
import { fakeAsync, TestBed, tick, flush, waitForAsync, ComponentFixture } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { IgxTooltipSingleTargetComponent, IgxTooltipMultipleTargetsComponent, IgxTooltipPlainStringComponent, IgxTooltipWithToggleActionComponent, IgxTooltipWithCloseButtonComponent, IgxTooltipWithNestedContentComponent, IgxTooltipNestedTooltipsComponent } from '../../../../test-utils/tooltip-components.spec';
import { UIInteractions } from '../../../../test-utils/ui-interactions.spec';
import { UIInteractions, wait } from '../../../../test-utils/ui-interactions.spec';
Comment thread
mddragnev marked this conversation as resolved.
import { HorizontalAlignment, VerticalAlignment, AutoPositionStrategy } from '../../../../core/src/services/public_api';
import { IgxTooltipDirective } from './tooltip.directive';
import { IgxTooltipTargetDirective } from './tooltip-target.directive';
Expand Down Expand Up @@ -1101,6 +1101,40 @@ describe('IgxTooltip', () => {
expect(closeBtn).toBeTruthy();
expect(tooltipNativeElement.getAttribute('role')).toBe('status');
}));

describe('Zoneless', () => {
beforeEach(async () => {
TestBed.resetTestingModule();
await TestBed.configureTestingModule({
imports: [
NoopAnimationsModule,
IgxTooltipWithCloseButtonComponent
],
providers: [provideZonelessChangeDetection()]
}).compileComponents();
});

beforeEach(() => {
fix = TestBed.createComponent(IgxTooltipWithCloseButtonComponent);
fix.detectChanges();
tooltipNativeElement = fix.debugElement.query(By.directive(IgxTooltipDirective)).nativeElement;
tooltipTarget = fix.componentInstance.tooltipTarget as IgxTooltipTargetDirective;
button = fix.debugElement.query(By.directive(IgxTooltipTargetDirective));
});

it('should not throw ExpressionChangedAfterItHasBeenChecked when showing sticky tooltip with close button', async () => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current test correctly covers the original ExpressionChangedAfterItHasBeenChecked regression when the sticky tooltip is shown. Since the implementation also adds markForCheck() when removing the close button, could we add coverage for that path as well? After showing the tooltip, set sticky to false, await fixture.whenStable(), and verify that the close button is removed and the role returns to "tooltip".

const errorHandler = TestBed.inject(ErrorHandler);
const handleErrorSpy = spyOn(errorHandler, 'handleError');

hoverElement(button);
await wait(SHOW_DELAY + 50);
fix.detectChanges();

expect(handleErrorSpy).not.toHaveBeenCalled();
verifyTooltipVisibility(tooltipNativeElement, tooltipTarget, true);
expect(tooltipNativeElement.getAttribute('role')).toBe('status');
});
Comment thread
mddragnev marked this conversation as resolved.
});
});

describe('IgxTooltip placement and offset', () => {
Expand Down
Loading