Skip to content

Commit

Permalink
fix(core): DropdownHover fix dropdown closing after child transition (
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimirpotekhin authored Oct 9, 2023
1 parent 9f727c2 commit a759118
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 15 deletions.
7 changes: 0 additions & 7 deletions projects/cdk/directives/hovered/hovered.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,6 @@ export class TuiHoveredService extends Observable<boolean> {
filter(movedOut),
map(ALWAYS_FALSE_HANDLER),
),
/**
* NOTE: onmouseout events don't trigger when objects move under mouse in Safari
* https://bugs.webkit.org/show_bug.cgi?id=4117
*/
tuiTypedFromEvent(this.el.nativeElement, `transitionend`).pipe(
map(() => this.el.nativeElement.matches(`:hover`)),
),
).pipe(distinctUntilChanged(), tuiZoneOptimized(this.zone));

constructor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,7 @@ export class TuiDropdownHoverDirective extends TuiDriver {
}

toggle(visible: boolean): void {
if (this.parentHover) {
this.parentHover.toggle(visible);
}

this.parentHover?.toggle(visible);
this.toggle$.next(visible);
}
}
5 changes: 3 additions & 2 deletions projects/core/directives/hint/hint-hover.directive.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* eslint-disable rxjs/no-unsafe-takeuntil */
import {Directive, ElementRef, Inject, Input} from '@angular/core';
import {TuiHoveredService} from '@taiga-ui/cdk';
import {tuiGetElementObscures, TuiHoveredService} from '@taiga-ui/cdk';
import {tuiAsDriver, TuiDriver} from '@taiga-ui/core/abstract';
import {merge, Observable, of, Subject} from 'rxjs';
import {delay, filter, repeat, switchMap, takeUntil, tap} from 'rxjs/operators';
import {delay, filter, map, repeat, switchMap, takeUntil, tap} from 'rxjs/operators';

import {TUI_HINT_OPTIONS, TuiHintOptions} from './hint-options.directive';

Expand All @@ -30,6 +30,7 @@ export class TuiHintHoverDirective extends TuiDriver {
),
).pipe(
filter(() => this.enabled),
map(value => value && !tuiGetElementObscures(this.el.nativeElement)?.length),
tap(visible => {
this.visible = visible;
}),
Expand Down
6 changes: 4 additions & 2 deletions projects/core/directives/hint/hint.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
tuiClamp,
TuiContextWithImplicit,
TuiDestroyService,
tuiGetElementObscures,
TuiHoveredService,
tuiPure,
tuiPx,
Expand Down Expand Up @@ -108,8 +109,9 @@ export class TuiHintComponent<C = any> {
@HostListener('document:click', ['$event.target'])
onClick(target: HTMLElement): void {
if (
!this.el.nativeElement.contains(target) &&
!this.hover.el.nativeElement.contains(target)
(!this.el.nativeElement.contains(target) &&
!this.hover.el.nativeElement.contains(target)) ||
tuiGetElementObscures(this.hover.el.nativeElement)?.length
) {
this.hover.toggle(false);
}
Expand Down

0 comments on commit a759118

Please sign in to comment.