Skip to content

Commit

Permalink
feat(experimental): add autoClose when another element is focused
Browse files Browse the repository at this point in the history
  • Loading branch information
MillerSvt committed Feb 15, 2024
1 parent ab0aba6 commit c1f3ff8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,20 @@ import {tuiGetActualTarget} from '@taiga-ui/cdk';
@Directive({
selector: 'tui-swipe-actions[autoClose]',
host: {
'(document:pointerdown.silent)': 'onPointer($event)',
'(document:pointerdown.silent)': 'handleEvent($event)',
'(document:focusin.silent)': 'handleEvent($event)',
},
})
export class TuiSwipeActionsAutoCloseDirective {
@Input()
autoClose = true;
autoClose: boolean | string = true;

constructor(@Inject(ElementRef) private readonly el: ElementRef<HTMLElement>) {}

onPointer(event: PointerEvent): void {
handleEvent(event: Event): void {
const target = tuiGetActualTarget(event);

if (this.autoClose && !this.el.nativeElement.contains(target)) {
if (this.autoClose !== false && !this.el.nativeElement.contains(target)) {
this.close();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
::ng-deep & > * {
.loop(6);
}

@media (hover: hover) and (pointer: fine) {
display: none;
}
}

.loop (@i) when (@i > 1) {
Expand Down

0 comments on commit c1f3ff8

Please sign in to comment.