Skip to content

Commit

Permalink
feat(core): add close methods for dropdown context directive
Browse files Browse the repository at this point in the history
  • Loading branch information
splincode committed Dec 18, 2024
1 parent c56cfbf commit fa419b5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()',
Expand All @@ -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 {

Check notice on line 55 in projects/core/directives/dropdown/dropdown-context.directive.ts

View check run for this annotation

codefactor.io / CodeFactor

projects/core/directives/dropdown/dropdown-context.directive.ts#L55

'_event' is defined but never used. (@typescript-eslint/no-unused-vars)
this.close();
}

protected onContextMenu(x: number, y: number): void {
this.currentRect = tuiPointToClientRect(x, y);
this.driver.next(true);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<p>
Make right click on this icon ->
<tui-icon
#dropdown="tuiDropdown"
#dropdown="tuiDropdownContext"
icon="@tui.settings"
tuiDropdownContext
class="icon"
Expand All @@ -15,7 +15,7 @@
size="s"
tuiIconButton
type="button"
(click)="dropdown.toggle(false)"
(click)="dropdown.close()"
>
Close
</button>
Expand Down

0 comments on commit fa419b5

Please sign in to comment.