Skip to content

Commit

Permalink
fix(core): Dialog should hide close icon if closeable equals to `…
Browse files Browse the repository at this point in the history
…Observable<false>`
  • Loading branch information
nsbarsukov committed Jul 25, 2024
1 parent 96c5656 commit 2d79f63
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
5 changes: 3 additions & 2 deletions projects/core/components/dialog/dialog.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
import {TuiDialogSize} from '@taiga-ui/core/types';
import {POLYMORPHEUS_CONTEXT, PolymorpheusContent} from '@tinkoff/ng-polymorpheus';
import {isObservable, merge, Observable, of, Subject} from 'rxjs';
import {filter, map, switchMap, takeUntil} from 'rxjs/operators';
import {filter, map, share, switchMap, takeUntil} from 'rxjs/operators';

import {TUI_DIALOGS_CLOSE} from './dialog.tokens';
import {TuiDialogCloseService} from './dialog-close.service';
Expand Down Expand Up @@ -64,6 +64,7 @@ export class TuiDialogComponent<O, I> {
} as const;

readonly close$ = new Subject();
readonly closeable$ = toObservable(this.context.closeable).pipe(share());

constructor(
@Inject(TUI_ANIMATIONS_DURATION) private readonly duration: number,
Expand All @@ -76,7 +77,7 @@ export class TuiDialogComponent<O, I> {
@Inject(TUI_COMMON_ICONS) readonly icons: TuiCommonIcons,
) {
merge(
this.close$.pipe(switchMap(() => toObservable(context.closeable))),
this.close$.pipe(switchMap(() => this.closeable$)),
dialogClose$.pipe(switchMap(() => toObservable(context.dismissible))),
close$.pipe(map(ALWAYS_TRUE_HANDLER)),
)
Expand Down
2 changes: 1 addition & 1 deletion projects/core/components/dialog/dialog.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
</div>
<div class="t-filler"></div>
<div
*ngIf="context.closeable"
*ngIf="closeable$ | async"
class="t-wrapper"
>
<button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export class TuiDialogExampleComponent8 {
onClick(content: PolymorpheusContent): void {
const closeable = this.dialogForm.withPrompt({
label: 'Are you sure?',
closeable: false,
dismissible: false,
data: {
content: 'Your data will be <strong>lost</strong>',
},
Expand Down

0 comments on commit 2d79f63

Please sign in to comment.