Skip to content

Commit

Permalink
fix(legacy): Input fix [(tuiDropdownOpen)] (#9214)
Browse files Browse the repository at this point in the history
  • Loading branch information
waterplea authored Sep 26, 2024
1 parent 1f5dfa5 commit 65981bc
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
9 changes: 7 additions & 2 deletions projects/kit/components/tabs/tab.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {tuiTypedFromEvent} from '@taiga-ui/cdk/observables';
import {tuiInjectElement} from '@taiga-ui/cdk/utils/dom';
import {tuiIsNativeFocused} from '@taiga-ui/cdk/utils/focus';
import {TuiWithIcons} from '@taiga-ui/core/directives/icons';
import {EMPTY, filter, merge} from 'rxjs';
import {EMPTY, filter, merge, switchMap} from 'rxjs';

export const TUI_TAB_ACTIVATE = 'tui-tab-activate';

Expand All @@ -32,7 +32,12 @@ export class TuiTab implements OnDestroy {
protected readonly sub = merge(
this.observer || EMPTY,
this.rla?.isActiveChange.pipe(filter(Boolean)) || EMPTY,
this.el.matches('button') ? tuiTypedFromEvent(this.el, 'click') : EMPTY,
this.el.matches('button')
? tuiTypedFromEvent(this.el, 'click').pipe(
// Delaying execution until after all other click callbacks
switchMap(() => tuiTypedFromEvent(this.el.parentElement!, 'click')),
)
: EMPTY,
)
.pipe(takeUntilDestroyed())
.subscribe(() =>
Expand Down
15 changes: 9 additions & 6 deletions projects/kit/pipes/filter-by-input/filter-by-input.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type {PipeTransform} from '@angular/core';
import {inject, Pipe} from '@angular/core';
import {TUI_DEFAULT_MATCHER} from '@taiga-ui/cdk/constants';
import type {TuiStringHandler, TuiStringMatcher} from '@taiga-ui/cdk/types';
import {tuiIsPresent, tuiPure} from '@taiga-ui/cdk/utils/miscellaneous';
import {tuiPure} from '@taiga-ui/cdk/utils/miscellaneous';
import {TUI_DATA_LIST_HOST} from '@taiga-ui/core/components/data-list';
import {TuiTextfieldComponent} from '@taiga-ui/core/components/textfield';
import {tuiIsFlat} from '@taiga-ui/kit/utils';
Expand Down Expand Up @@ -57,7 +57,7 @@ export class TuiFilterByInputPipe implements PipeTransform {
): readonly T[] {
const match = this.getMatch(items, stringify, query);

return tuiIsPresent(match)
return match != null
? items
: items.filter((item) => matcher(item, query, stringify));
}
Expand All @@ -68,11 +68,9 @@ export class TuiFilterByInputPipe implements PipeTransform {
stringify: TuiStringHandler<T>,
query: string,
): ReadonlyArray<readonly T[]> {
const match = items.find((item) =>
tuiIsPresent(this.getMatch(item, stringify, query)),
);
const match = items.find((item) => this.getMatch(item, stringify, query) != null);

return tuiIsPresent(match)
return match != null
? items
: items.map((inner) => this.filterFlat(inner, matcher, stringify, query));
}
Expand All @@ -82,6 +80,11 @@ export class TuiFilterByInputPipe implements PipeTransform {
stringify: TuiStringHandler<T>,
query: string,
): T | undefined {
// TODO: Refactor when tui-textfield[multi] is ready
if ((this.host as any).tagValidator) {
return undefined;
}

return items.find(
(item) => stringify(item).toLocaleLowerCase() === query.toLocaleLowerCase(),
);
Expand Down
8 changes: 7 additions & 1 deletion projects/legacy/components/input/input.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,18 @@ import {
TuiPrimitiveTextfieldModule,
TuiTextfieldComponent,
} from '@taiga-ui/legacy/components/primitive-textfield';
import {TuiLegacyDropdownOpenMonitorDirective} from '@taiga-ui/legacy/directives';

import {TuiInputComponent} from './input.component';
import {TuiInputDirective} from './input.directive';

@NgModule({
imports: [CommonModule, TuiPrimitiveTextfieldModule, ...TuiDropdown],
imports: [
CommonModule,
TuiPrimitiveTextfieldModule,
...TuiDropdown,
TuiLegacyDropdownOpenMonitorDirective,
],
declarations: [TuiInputComponent, TuiInputDirective],
exports: [
TuiInputComponent,
Expand Down

0 comments on commit 65981bc

Please sign in to comment.