Skip to content

Commit

Permalink
fix(overlay): change how containers are hidden (#14182)
Browse files Browse the repository at this point in the history
  • Loading branch information
simeonoff authored Apr 30, 2024
1 parent 9453539 commit 5c48edf
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,9 @@
@include m(hidden) {
@extend %igx-toggle--hidden !optional;
}

@include m(hidden-webkit) {
@extend %igx-toggle--hidden-webkit !optional;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,23 @@
position: relative;
}

%igx-toggle--hidden {
%igx-toggle--hidden:not(%igx-toggle--hidden-webkit) {
display: none !important;
}

%igx-toggle--hidden-webkit {
// WARN: This is a workaround around a bug in Safari.
position: absolute;
visibility: hidden;
top: 0;
left: 0;
margin: -1px;
border: none;
clip: rect(0, 0, 0, 0);
outline: 0;
pointer-events: none;
overflow: hidden;
appearance: none;
z-index: -1;
}
}
2 changes: 2 additions & 0 deletions projects/igniteui-angular/src/lib/core/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,12 @@ export const isEqual = (obj1, obj2): boolean => {
export class PlatformUtil {
public isBrowser: boolean = isPlatformBrowser(this.platformId);
public isIOS = this.isBrowser && /iPad|iPhone|iPod/.test(navigator.userAgent) && !('MSStream' in window);
public isSafari = this.isBrowser && /Safari[\/\s](\d+\.\d+)/.test(navigator.userAgent);

Check warning on line 248 in projects/igniteui-angular/src/lib/core/utils.ts

View workflow job for this annotation

GitHub Actions / run-tests (18.x)

Unnecessary escape character: \/

Check warning on line 248 in projects/igniteui-angular/src/lib/core/utils.ts

View workflow job for this annotation

GitHub Actions / run-tests (20.x)

Unnecessary escape character: \/
public isFirefox = this.isBrowser && /Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent);

Check warning on line 249 in projects/igniteui-angular/src/lib/core/utils.ts

View workflow job for this annotation

GitHub Actions / run-tests (18.x)

Unnecessary escape character: \/

Check warning on line 249 in projects/igniteui-angular/src/lib/core/utils.ts

View workflow job for this annotation

GitHub Actions / run-tests (20.x)

Unnecessary escape character: \/
public isEdge = this.isBrowser && /Edge[\/\s](\d+\.\d+)/.test(navigator.userAgent);

Check warning on line 250 in projects/igniteui-angular/src/lib/core/utils.ts

View workflow job for this annotation

GitHub Actions / run-tests (18.x)

Unnecessary escape character: \/

Check warning on line 250 in projects/igniteui-angular/src/lib/core/utils.ts

View workflow job for this annotation

GitHub Actions / run-tests (20.x)

Unnecessary escape character: \/
public isChromium = this.isBrowser && (/Chrom|e?ium/g.test(navigator.userAgent) ||
/Google Inc/g.test(navigator.vendor)) && !/Edge/g.test(navigator.userAgent);
public browserVersion = this.isBrowser ? parseFloat(navigator.userAgent.match(/Version\/([\d.]+)/)?.at(1)) : 0;

public KEYMAP = mkenum({
ENTER: 'Enter',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
Output
} from '@angular/core';
import { AbsoluteScrollStrategy } from '../../services/overlay/scroll/absolute-scroll-strategy';
import { CancelableBrowserEventArgs, IBaseEventArgs } from '../../core/utils';
import { CancelableBrowserEventArgs, IBaseEventArgs, PlatformUtil } from '../../core/utils';
import { ConnectedPositioningStrategy } from '../../services/overlay/position/connected-positioning-strategy';
import { filter, first, takeUntil } from 'rxjs/operators';
import { IgxNavigationService, IToggleView } from '../../core/navigation';
Expand Down Expand Up @@ -164,6 +164,14 @@ export class IgxToggleDirective implements IToggleView, OnInit, OnDestroy {
return this.collapsed;
}

@HostBinding('class.igx-toggle--hidden-webkit')
public get hiddenWebkitClass() {
const isSafari = this.platform?.isSafari;
const browserVersion = this.platform?.browserVersion;

return this.collapsed && isSafari && !!browserVersion && browserVersion < 17.5;
}

/**
* @hidden
*/
Expand Down Expand Up @@ -192,7 +200,9 @@ export class IgxToggleDirective implements IToggleView, OnInit, OnDestroy {
private elementRef: ElementRef,
private cdr: ChangeDetectorRef,
@Inject(IgxOverlayService) protected overlayService: IgxOverlayService,
@Optional() private navigationService: IgxNavigationService) {
@Optional() private navigationService: IgxNavigationService,
@Optional() private platform?: PlatformUtil
) {
}

/**
Expand Down

0 comments on commit 5c48edf

Please sign in to comment.