diff --git a/projects/igniteui-angular/src/lib/core/utils.ts b/projects/igniteui-angular/src/lib/core/utils.ts index 1481ae973af..4a62129e24f 100644 --- a/projects/igniteui-angular/src/lib/core/utils.ts +++ b/projects/igniteui-angular/src/lib/core/utils.ts @@ -226,6 +226,17 @@ export function isFirefox(): boolean { return firefoxBrowser; } +/** + * @hidden + * TODO: make injectable, check isPlatformBrowser() + */ +export class PlatformUtil { + static isIOS(): boolean { + const iosBrowser = typeof window !== 'undefined' && /iPad|iPhone|iPod/.test(navigator.userAgent) && !('MSStream' in window); + return iosBrowser; + } +} + /** * @hidden */ diff --git a/projects/igniteui-angular/src/lib/grids/cell.component.ts b/projects/igniteui-angular/src/lib/grids/cell.component.ts index bd3d5b5062b..b017ff0874c 100644 --- a/projects/igniteui-angular/src/lib/grids/cell.component.ts +++ b/projects/igniteui-angular/src/lib/grids/cell.component.ts @@ -18,7 +18,9 @@ import { IgxSelectionAPIService } from '../core/selection'; import { IgxTextHighlightDirective } from '../directives/text-highlight/text-highlight.directive'; import { GridBaseAPIService } from './api.service'; import { IgxColumnComponent } from './column.component'; -import { getNodeSizeViaRange, ROW_COLLAPSE_KEYS, ROW_EXPAND_KEYS, SUPPORTED_KEYS, NAVIGATION_KEYS, isIE, isLeftClick } from '../core/utils'; +import { + getNodeSizeViaRange, ROW_COLLAPSE_KEYS, ROW_EXPAND_KEYS, SUPPORTED_KEYS, NAVIGATION_KEYS, isIE, isLeftClick, PlatformUtil +} from '../core/utils'; import { State } from '../services/index'; import { IgxGridBaseComponent, IGridEditEventArgs, IGridDataBindable } from './grid-base.component'; import { IgxGridSelectionService, ISelectionNode, IgxGridCRUDService } from '../core/grid-selection'; @@ -555,9 +557,11 @@ export class IgxGridCellComponent implements OnInit, OnChanges, OnDestroy { this.nativeElement.addEventListener('compositionend', this.compositionEndHandler); } }); - this.touchManager.addEventListener(this.nativeElement, 'doubletap', this.onDoubleClick, { - cssProps: { } /* don't disable user-select, etc */ - } as HammerOptions); + if (PlatformUtil.isIOS()) { + this.touchManager.addEventListener(this.nativeElement, 'doubletap', this.onDoubleClick, { + cssProps: { } /* don't disable user-select, etc */ + } as HammerOptions); + } } /** diff --git a/projects/igniteui-angular/src/lib/grids/grid/cell.spec.ts b/projects/igniteui-angular/src/lib/grids/grid/cell.spec.ts index d1e411d7859..f5901dc029f 100644 --- a/projects/igniteui-angular/src/lib/grids/grid/cell.spec.ts +++ b/projects/igniteui-angular/src/lib/grids/grid/cell.spec.ts @@ -9,6 +9,7 @@ import { configureTestSuite } from '../../test-utils/configure-suite'; import { IgxStringFilteringOperand } from '../../data-operations/filtering-condition'; import { SampleTestData } from '../../test-utils/sample-test-data.spec'; import { HammerGesturesManager } from '../../core/touch'; +import { PlatformUtil } from '../../core/utils'; const DEBOUNCETIME = 30; @@ -186,8 +187,16 @@ describe('IgxGrid - Cell component', () => { expect(firstCell).toBe(fix.componentInstance.clickedCell); }); - it('Should handle doubletap, trigger onDoubleClick event', () => { + it('Should not attach doubletap handler for non-iOS', () => { const addListenerSpy = spyOn(HammerGesturesManager.prototype, 'addEventListener'); + spyOn(PlatformUtil, 'isIOS').and.returnValue(false); + const fix = TestBed.createComponent(DefaultGridComponent); + fix.detectChanges(); + }); + + it('Should handle doubletap on iOS, trigger onDoubleClick event', () => { + const addListenerSpy = spyOn(HammerGesturesManager.prototype, 'addEventListener'); + spyOn(PlatformUtil, 'isIOS').and.returnValue(true); const fix = TestBed.createComponent(DefaultGridComponent); fix.detectChanges();