-
Notifications
You must be signed in to change notification settings - Fork 159
fix(tooltip): mark tooltip as dirty when changing its role #17382
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
5929899
b9ebeff
623d8a9
dd7e690
dfad459
e3f4716
3d77848
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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'; | ||
|
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'; | ||
|
|
@@ -1101,6 +1101,61 @@ 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 () => { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The current test correctly covers the original
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
| 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'); | ||
| }); | ||
|
|
||
| it('should correctly remove the close button and update the role when sticky is set to false', async () => { | ||
| tooltipTarget.sticky = true; | ||
| fix.detectChanges(); | ||
| hoverElement(button); | ||
| await wait(SHOW_DELAY + 50); | ||
| fix.detectChanges(); | ||
|
|
||
| const closeBtn = tooltipNativeElement.querySelector('igx-tooltip-close-button'); | ||
| expect(closeBtn).not.toBeNull(); | ||
| expect(fix.componentInstance.tooltip.role).toBe('status'); | ||
|
|
||
| tooltipTarget.sticky = false; | ||
| fix.detectChanges(); | ||
| hoverElement(button); | ||
| await wait(SHOW_DELAY + 50); | ||
| fix.detectChanges(); | ||
|
|
||
| expect(fix.componentInstance.tooltip.role).toBe('tooltip'); | ||
| expect(tooltipNativeElement.querySelector('igx-tooltip-close-button')).toBeNull(); | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
| describe('IgxTooltip placement and offset', () => { | ||
|
|
@@ -1188,7 +1243,7 @@ const alignmentTolerance = 2; | |
| export const verifyTooltipPosition = ( | ||
| tooltipNativeElement: HTMLElement, | ||
| actualTarget: { nativeElement: HTMLElement }, | ||
| shouldAlign:boolean = true, | ||
| shouldAlign: boolean = true, | ||
| placement: Placement = Placement.Bottom, | ||
| offset: number = 6 | ||
| ) => { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.