Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): emit tuiDropdownOpenChange on distinct values #9962

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Directive, Input, Output} from '@angular/core';
import {BehaviorSubject} from 'rxjs';
import {distinctUntilChanged, Subject} from 'rxjs';

/**
* @deprecated TODO: remove in v.5 when legacy controls are dropped
Expand All @@ -10,11 +10,19 @@ import {BehaviorSubject} from 'rxjs';
'[tuiDropdownOpen]:not([tuiDropdown]),[tuiDropdownOpenChange]:not([tuiDropdown])',
})
export class TuiDropdownOpenLegacy {
private readonly openStateSub = new Subject<boolean>();

@Output()
public readonly tuiDropdownOpenChange = new BehaviorSubject(false);
public readonly tuiDropdownOpenChange = this.openStateSub
.asObservable()
splincode marked this conversation as resolved.
Show resolved Hide resolved
.pipe(distinctUntilChanged());

@Input()
public set tuiDropdownOpen(open: boolean) {
this.tuiDropdownOpenChange.next(open);
this.emitOpenChange(open);
}

public emitOpenChange(open: boolean): void {
this.openStateSub.next(open);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ export class TuiLegacyDropdownOpenMonitorDirective implements AfterViewInit {

this.host.driver
.pipe(distinctUntilChanged(), takeUntilDestroyed(this.destroyRef))
.subscribe((open) => this.external?.tuiDropdownOpenChange.next(open));
.subscribe((open) => this.external?.emitOpenChange(open));
}
}
Loading