Skip to content

Commit

Permalink
feat(experimental): add autoClose when another element is focused, hi…
Browse files Browse the repository at this point in the history
…de actions on non-touch devices (#6801)
  • Loading branch information
MillerSvt authored Feb 16, 2024
1 parent 069a650 commit 447baca
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
width: 20rem;
}

tui-swipe-actions {
overflow: hidden;
}

.fallback {
.center-top();
right: 2rem;
Expand All @@ -26,8 +22,4 @@ button[tuiSwipeAction] {
.fallback {
display: none;
}

tui-swipe-actions {
overflow-x: scroll;
}
}
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 447baca

Please sign in to comment.