Skip to content

Commit

Permalink
fix(core): emit tuiDropdownOpenChange on distinct values (#9962)
Browse files Browse the repository at this point in the history
  • Loading branch information
shiv9604 authored Dec 13, 2024
1 parent 9d0e6a7 commit f8ea2f2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
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,18 @@ 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.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));
}
}

0 comments on commit f8ea2f2

Please sign in to comment.