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(cdk): FocusTrap blur manually to prevent ExpressionChanged error #40

Merged
merged 2 commits into from
Nov 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
14 changes: 7 additions & 7 deletions projects/cdk/constants/matcher.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {TuiIdentityMatcher, TuiMatcher, TuiStringHandler} from '@taiga-ui/cdk/types';
import {TuiIdentityMatcher, TuiStringHandler} from '@taiga-ui/cdk/types';
import {TUI_DEFAULT_STRINGIFY} from './stringify';

/**
Expand All @@ -7,10 +7,10 @@ import {TUI_DEFAULT_STRINGIFY} from './stringify';
* @param search search query
* @param stringify handler to turn item into a string
*/
export const TUI_DEFAULT_MATCHER: TuiMatcher<any> = (
item,
export const TUI_DEFAULT_MATCHER = <T>(
item: T,
search: string,
stringify: TuiStringHandler<any> = TUI_DEFAULT_STRINGIFY,
stringify: TuiStringHandler<T> = TUI_DEFAULT_STRINGIFY,
) => stringify(item).toLowerCase().includes(search.toLowerCase());

/**
Expand All @@ -19,10 +19,10 @@ export const TUI_DEFAULT_MATCHER: TuiMatcher<any> = (
* @param search search query
* @param stringify handler to turn item into a string
*/
export const TUI_STRICT_MATCHER: TuiMatcher<any> = (
item,
export const TUI_STRICT_MATCHER = <T>(
item: T,
search: string,
stringify: TuiStringHandler<any> = TUI_DEFAULT_STRINGIFY,
stringify: TuiStringHandler<T> = TUI_DEFAULT_STRINGIFY,
) => stringify(item).toLowerCase() === search.toLowerCase();

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ export class TuiFocusTrapDirective implements AfterViewInit, OnDestroy {
@Inject(ElementRef)
private readonly elementRef: ElementRef<HTMLElement>,
@Inject(Renderer2) private readonly renderer: Renderer2,
) {}
) {
if (this.activeElement instanceof HTMLElement) {
setNativeFocused(this.activeElement, false);
}
}

ngAfterViewInit() {
setNativeFocused(this.elementRef.nativeElement);
Expand Down