Skip to content

Commit 0814c80

Browse files
authored
fix(overlay): change how containers are hidden (#14167)
1 parent af32c85 commit 0814c80

File tree

4 files changed

+35
-3
lines changed

4 files changed

+35
-3
lines changed

projects/igniteui-angular/src/lib/core/styles/components/overlay/_overlay-component.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,9 @@
5656
@include m(hidden) {
5757
@extend %igx-toggle--hidden !optional;
5858
}
59+
60+
@include m(hidden-webkit) {
61+
@extend %igx-toggle--hidden-webkit !optional;
62+
}
5963
}
6064
}

projects/igniteui-angular/src/lib/core/styles/components/overlay/_overlay-theme.scss

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,23 @@
9494
position: relative;
9595
}
9696

97-
%igx-toggle--hidden {
97+
%igx-toggle--hidden:not(%igx-toggle--hidden-webkit) {
9898
display: none !important;
9999
}
100+
101+
%igx-toggle--hidden-webkit {
102+
// WARN: This is a workaround around a bug in Safari.
103+
position: absolute;
104+
visibility: hidden;
105+
top: 0;
106+
left: 0;
107+
margin: -1px;
108+
border: none;
109+
clip: rect(0, 0, 0, 0);
110+
outline: 0;
111+
pointer-events: none;
112+
overflow: hidden;
113+
appearance: none;
114+
z-index: -1;
115+
}
100116
}

projects/igniteui-angular/src/lib/core/utils.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,10 +245,12 @@ export const isEqual = (obj1, obj2): boolean => {
245245
export class PlatformUtil {
246246
public isBrowser: boolean = isPlatformBrowser(this.platformId);
247247
public isIOS = this.isBrowser && /iPad|iPhone|iPod/.test(navigator.userAgent) && !('MSStream' in window);
248+
public isSafari = this.isBrowser && /Safari[\/\s](\d+\.\d+)/.test(navigator.userAgent);
248249
public isFirefox = this.isBrowser && /Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent);
249250
public isEdge = this.isBrowser && /Edge[\/\s](\d+\.\d+)/.test(navigator.userAgent);
250251
public isChromium = this.isBrowser && (/Chrom|e?ium/g.test(navigator.userAgent) ||
251252
/Google Inc/g.test(navigator.vendor)) && !/Edge/g.test(navigator.userAgent);
253+
public browserVersion = this.isBrowser ? parseFloat(navigator.userAgent.match(/Version\/([\d.]+)/)?.at(1)) : 0;
252254

253255
public KEYMAP = mkenum({
254256
ENTER: 'Enter',

projects/igniteui-angular/src/lib/directives/toggle/toggle.directive.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
Output
1414
} from '@angular/core';
1515
import { AbsoluteScrollStrategy } from '../../services/overlay/scroll/absolute-scroll-strategy';
16-
import { CancelableBrowserEventArgs, IBaseEventArgs } from '../../core/utils';
16+
import { CancelableBrowserEventArgs, IBaseEventArgs, PlatformUtil } from '../../core/utils';
1717
import { ConnectedPositioningStrategy } from '../../services/overlay/position/connected-positioning-strategy';
1818
import { filter, first, takeUntil } from 'rxjs/operators';
1919
import { IgxNavigationService, IToggleView } from '../../core/navigation';
@@ -164,6 +164,14 @@ export class IgxToggleDirective implements IToggleView, OnInit, OnDestroy {
164164
return this.collapsed;
165165
}
166166

167+
@HostBinding('class.igx-toggle--hidden-webkit')
168+
public get hiddenWebkitClass() {
169+
const isSafari = this.platform?.isSafari;
170+
const browserVersion = this.platform?.browserVersion;
171+
172+
return this.collapsed && isSafari && !!browserVersion && browserVersion < 17.5;
173+
}
174+
167175
/**
168176
* @hidden
169177
*/
@@ -192,7 +200,9 @@ export class IgxToggleDirective implements IToggleView, OnInit, OnDestroy {
192200
private elementRef: ElementRef,
193201
private cdr: ChangeDetectorRef,
194202
@Inject(IgxOverlayService) protected overlayService: IgxOverlayService,
195-
@Optional() private navigationService: IgxNavigationService) {
203+
@Optional() private navigationService: IgxNavigationService,
204+
@Optional() private platform?: PlatformUtil
205+
) {
196206
}
197207

198208
/**

0 commit comments

Comments
 (0)