mirror of
https://github.com/bitwarden/browser
synced 2025-12-19 09:43:23 +00:00
[PM-15847] libs/components strict migration (#15738)
This PR migrates `libs/components` to use strict TypeScript. - Remove `@ts-strict-ignore` from each file in `libs/components` and resolved any new compilation errors - Converted ViewChild and ContentChild decorators to use the new signal-based queries using the [Angular signal queries migration](https://angular.dev/reference/migrations/signal-queries) - Made view/content children `required` where appropriate, eliminating the need for additional null checking. This helped simplify the strict migration. --- Co-authored-by: Vicki League <vleague@bitwarden.com>
This commit is contained in:
@@ -1,14 +1,5 @@
|
||||
// FIXME: Update this file to be type safe and remove this and next line
|
||||
// @ts-strict-ignore
|
||||
import { FocusKeyManager } from "@angular/cdk/a11y";
|
||||
import {
|
||||
AfterContentInit,
|
||||
Component,
|
||||
ContentChildren,
|
||||
forwardRef,
|
||||
QueryList,
|
||||
input,
|
||||
} from "@angular/core";
|
||||
import { AfterContentInit, Component, forwardRef, input, contentChildren } from "@angular/core";
|
||||
|
||||
import { TabHeaderComponent } from "../shared/tab-header.component";
|
||||
import { TabListContainerDirective } from "../shared/tab-list-container.directive";
|
||||
@@ -24,17 +15,17 @@ import { TabLinkComponent } from "./tab-link.component";
|
||||
imports: [TabHeaderComponent, TabListContainerDirective],
|
||||
})
|
||||
export class TabNavBarComponent implements AfterContentInit {
|
||||
@ContentChildren(forwardRef(() => TabLinkComponent)) tabLabels: QueryList<TabLinkComponent>;
|
||||
readonly tabLabels = contentChildren(forwardRef(() => TabLinkComponent));
|
||||
readonly label = input("");
|
||||
|
||||
/**
|
||||
* Focus key manager for keeping tab controls accessible.
|
||||
* https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/tablist_role#keyboard_interactions
|
||||
*/
|
||||
keyManager: FocusKeyManager<TabLinkComponent>;
|
||||
keyManager?: FocusKeyManager<TabLinkComponent>;
|
||||
|
||||
ngAfterContentInit(): void {
|
||||
this.keyManager = new FocusKeyManager(this.tabLabels)
|
||||
this.keyManager = new FocusKeyManager(this.tabLabels())
|
||||
.withHorizontalOrientation("ltr")
|
||||
.withWrap()
|
||||
.withHomeAndEnd();
|
||||
@@ -42,10 +33,10 @@ export class TabNavBarComponent implements AfterContentInit {
|
||||
|
||||
updateActiveLink() {
|
||||
// Keep the keyManager in sync with active tabs
|
||||
const items = this.tabLabels.toArray();
|
||||
const items = this.tabLabels();
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
if (items[i].active) {
|
||||
this.keyManager.updateActiveItem(i);
|
||||
this.keyManager?.updateActiveItem(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user