-
Notifications
You must be signed in to change notification settings - Fork 472
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(core):
Dropdown
fix for initial open state (#6130)
- Loading branch information
Showing
2 changed files
with
22 additions
and
7 deletions.
There are no files selected for viewing
17 changes: 12 additions & 5 deletions
17
projects/core/directives/dropdown/dropdown-open.directive.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,25 @@ | ||
import {Directive, EventEmitter, Input, Output} from '@angular/core'; | ||
import {Directive, EventEmitter, Input, OnChanges, Output} from '@angular/core'; | ||
|
||
import type {TuiDropdownDirective} from './dropdown.directive'; | ||
|
||
@Directive({ | ||
selector: '[tuiDropdownOpen],[tuiDropdownOpenChange]', | ||
}) | ||
export class TuiDropdownOpenDirective { | ||
export class TuiDropdownOpenDirective implements OnChanges { | ||
@Input() | ||
set tuiDropdownOpen(open: boolean) { | ||
this.dropdown?.toggle(open); | ||
} | ||
tuiDropdownOpen = false; | ||
|
||
@Output() | ||
readonly tuiDropdownOpenChange = new EventEmitter<boolean>(); | ||
|
||
dropdown?: TuiDropdownDirective; | ||
|
||
update(open: boolean): void { | ||
this.tuiDropdownOpen = open; | ||
this.tuiDropdownOpenChange.emit(open); | ||
} | ||
|
||
ngOnChanges(): void { | ||
this.dropdown?.toggle(this.tuiDropdownOpen); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters