From e76e27ebe0cde3f4993e381eb4600e4821702181 Mon Sep 17 00:00:00 2001 From: Alex Inkin Date: Tue, 24 Sep 2024 20:02:09 +0400 Subject: [PATCH] fix(core): `DropdownContext` fix for Shadow DOM (#9171) --- .../dropdown/dropdown-context.directive.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/projects/core/directives/dropdown/dropdown-context.directive.ts b/projects/core/directives/dropdown/dropdown-context.directive.ts index 24ef09fda362..ed2cab7a2252 100644 --- a/projects/core/directives/dropdown/dropdown-context.directive.ts +++ b/projects/core/directives/dropdown/dropdown-context.directive.ts @@ -2,14 +2,14 @@ import {computed, Directive, inject} from '@angular/core'; import {EMPTY_CLIENT_RECT} from '@taiga-ui/cdk/constants'; import {TuiActiveZone} from '@taiga-ui/cdk/directives/active-zone'; import {TUI_IS_IOS, TUI_IS_TOUCH} from '@taiga-ui/cdk/tokens'; -import {tuiPointToClientRect} from '@taiga-ui/cdk/utils/dom'; +import {tuiGetActualTarget, tuiPointToClientRect} from '@taiga-ui/cdk/utils/dom'; import {tuiAsDriver, tuiAsRectAccessor, TuiRectAccessor} from '@taiga-ui/core/classes'; import {shouldCall} from '@taiga-ui/event-plugins'; import {TuiDropdownDriver} from './dropdown.driver'; -function activeZoneFilter(this: TuiDropdownContext, target: Element): boolean { - return !this.activeZone.contains(target); +function activeZoneFilter(this: TuiDropdownContext, event?: Event): boolean { + return !event || !this.activeZone.contains(tuiGetActualTarget(event)); } const TAP_DELAY = 700; @@ -34,9 +34,9 @@ const MOVE_THRESHOLD = 15; 'onTouchMove($event.touches[0].clientX, $event.touches[0].clientY)', '(touchstart.silent.passive)': 'onTouchStart($event.touches[0].clientX, $event.touches[0].clientY)', - '(document:pointerdown.silent)': 'closeDropdown($event.target)', - '(document:contextmenu.capture.silent)': 'closeDropdown($event.target)', - '(document:keydown.esc)': 'closeDropdown($event.currentTarget)', + '(document:pointerdown.silent)': 'closeDropdown($event)', + '(document:contextmenu.capture.silent)': 'closeDropdown($event)', + '(document:keydown.esc)': 'closeDropdown()', '(contextmenu.prevent.stop)': 'onContextMenu($event.clientX, $event.clientY)', }, }) @@ -57,7 +57,7 @@ export class TuiDropdownContext extends TuiRectAccessor { } @shouldCall(activeZoneFilter) - protected closeDropdown(_element: Element): void { + protected closeDropdown(_event?: Event): void { this.driver.next(false); this.currentRect = EMPTY_CLIENT_RECT; }