Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | 1x 21x 21x 21x 3x 3x 3x 3x 3x | /**
* Copyright (c) Siemens 2016 - 2025
* SPDX-License-Identifier: MIT
*/
import { ChangeDetectionStrategy, Component, ElementRef, inject } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { SiListDetailsComponent } from '../si-list-details.component';
/** @experimental */
@Component({
selector: 'si-list-pane',
templateUrl: './si-list-pane.component.html',
styleUrl: './si-list-pane.component.scss',
changeDetection: ChangeDetectionStrategy.OnPush,
host: {
'[class.expanded]': 'parent.hasLargeSize()',
'[class.details-active]': 'parent.detailsActive() && !parent.hasLargeSize()',
'[attr.inert]': '!parent.hasLargeSize() && parent.detailsActive() ? "" : null',
'[attr.tabindex]': '-1',
'[style.flex-basis.%]':
'parent.hasLargeSize() && parent.disableResizing() ? parent.listWidth() : undefined'
}
})
export class SiListPaneComponent {
protected parent = inject(SiListDetailsComponent);
private element: ElementRef<HTMLElement> = inject(ElementRef);
constructor() {
this.parent.transferFocusToList
.pipe(takeUntilDestroyed())
.subscribe(previouslyFocusedElement => {
// Needed so it's no longer "inert".
setTimeout(() => {
const currentlyFocused = document?.activeElement;
previouslyFocusedElement?.focus();
// If there was no previously focused element or if it couldn't be focused anymore, fall back to the focusing the list.
if (currentlyFocused === document?.activeElement) {
this.element?.nativeElement?.focus();
}
});
});
}
}
|