diff --git a/projects/core/directives/dropdown/dropdown-context.directive.ts b/projects/core/directives/dropdown/dropdown-context.directive.ts index 812fcaeef024..221e10751f88 100644 --- a/projects/core/directives/dropdown/dropdown-context.directive.ts +++ b/projects/core/directives/dropdown/dropdown-context.directive.ts @@ -21,6 +21,7 @@ function activeZoneFilter(this: TuiDropdownContext, event?: Event): boolean { tuiAsDriver(TuiDropdownDriver), tuiAsRectAccessor(TuiDropdownContext), ], + exportAs: 'tuiDropdownContext', host: { '[style.user-select]': 'userSelect()', '[style.-webkit-user-select]': 'userSelect()', @@ -45,12 +46,16 @@ export class TuiDropdownContext extends TuiRectAccessor { return this.currentRect; } - @shouldCall(activeZoneFilter) - protected closeDropdown(_event?: Event): void { + public close(): void { this.driver.next(false); this.currentRect = EMPTY_CLIENT_RECT; } + @shouldCall(activeZoneFilter) + protected closeDropdown(_event?: Event): void { + this.close(); + } + protected onContextMenu(x: number, y: number): void { this.currentRect = tuiPointToClientRect(x, y); this.driver.next(true); diff --git a/projects/demo/src/modules/directives/dropdown-context/examples/1/index.html b/projects/demo/src/modules/directives/dropdown-context/examples/1/index.html index 460121018728..4599664b2380 100644 --- a/projects/demo/src/modules/directives/dropdown-context/examples/1/index.html +++ b/projects/demo/src/modules/directives/dropdown-context/examples/1/index.html @@ -1,7 +1,7 @@

Make right click on this icon -> Close