Skip to content

Commit 3ba2120

Browse files
committed
fix(overlay): change cursor in iOS, #5853
1 parent 07739ba commit 3ba2120

File tree

1 file changed

+19
-1
lines changed
  • projects/igniteui-angular/src/lib/services/overlay

1 file changed

+19
-1
lines changed

projects/igniteui-angular/src/lib/services/overlay/overlay.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { fromEvent, Subject, Subscription } from 'rxjs';
1717
import { filter, takeUntil } from 'rxjs/operators';
1818
import { IAnimationParams } from '../../animations/main';
1919
import { showMessage } from '../../core/deprecateDecorators';
20+
import { PlatformUtil } from '../../core/utils';
2021
import { GlobalPositionStrategy } from './position/global-position-strategy';
2122
import { NoOpScrollStrategy } from './scroll/NoOpScrollStrategy';
2223
import {
@@ -41,6 +42,8 @@ export class IgxOverlayService implements OnDestroy {
4142
private _document: Document;
4243
private _keyPressEventListener: Subscription;
4344
private destroy$ = new Subject<boolean>();
45+
private _cursorStyleIsSet = false;
46+
private _cursorOriginalValue: string;
4447

4548
private _defaultSettings: OverlaySettings = {
4649
positionStrategy: new GlobalPositionStrategy(),
@@ -116,7 +119,8 @@ export class IgxOverlayService implements OnDestroy {
116119
private _injector: Injector,
117120
private builder: AnimationBuilder,
118121
@Inject(DOCUMENT) private document: any,
119-
private _zone: NgZone) {
122+
private _zone: NgZone,
123+
protected platformUtil: PlatformUtil) {
120124
this._document = <Document>this.document;
121125
}
122126

@@ -683,6 +687,15 @@ export class IgxOverlayService implements OnDestroy {
683687
this._overlayInfos.filter(x => x.settings.closeOnOutsideClick && !x.settings.modal &&
684688
x.closeAnimationPlayer &&
685689
x.closeAnimationPlayer.hasStarted()).length === 1) {
690+
691+
// click event is not fired on iOS. To make element "clickable" we are
692+
// setting the cursor to pointer
693+
if (this.platformUtil.isIOS && !this._cursorStyleIsSet) {
694+
this._cursorOriginalValue = this._document.body.style.cursor;
695+
this._document.body.style.cursor = 'pointer';
696+
this._cursorStyleIsSet = true;
697+
}
698+
686699
this._document.addEventListener('click', this.documentClicked, true);
687700
}
688701
}
@@ -698,6 +711,11 @@ export class IgxOverlayService implements OnDestroy {
698711
});
699712

700713
if (shouldRemoveClickEventListener) {
714+
if (this._cursorStyleIsSet) {
715+
this._document.body.style.cursor = this._cursorOriginalValue;
716+
this._cursorOriginalValue = '';
717+
this._cursorStyleIsSet = false;
718+
}
701719
this._document.removeEventListener('click', this.documentClicked, true);
702720
}
703721
}

0 commit comments

Comments
 (0)