Skip to content

Commit 5687b2f

Browse files
committed
fix(docs-infra): keep focus in the API reference filter
The API reference filter writes its value to the URL on each change. With the Navigation API integration, each of these navigations ends with the browser moving focus to the body, so typing `signal` in the filter leaves `s` and the other keys go to the page. Pass `focusReset: 'manual'` next to `scroll: 'manual'`, so focus stays in the filter field. The option isn't in the router's public types on this branch, hence the cast.
1 parent eac23af commit 5687b2f

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

‎adev/src/app/features/references/api-reference-list/api-reference-list.component.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import {
2121
import {Select, SelectOption, TextField} from '@angular/docs';
2222
import {FormField, form} from '@angular/forms/signals';
2323
import {MatChipListbox, MatChipOption} from '@angular/material/chips';
24-
import {Params, Router} from '@angular/router';
24+
import {NavigationExtras, Params, Router} from '@angular/router';
2525
import ApiItemLabel from '../api-item-label/api-item-label.component';
2626
import ApiItemsSection from '../api-items-section/api-items-section.component';
2727
import {ApiItemType} from '../interfaces/api-item-type';
@@ -164,7 +164,10 @@ export default class ApiReferenceList {
164164
replaceUrl: true,
165165
preserveFragment: true,
166166
scroll: 'manual',
167-
});
167+
// Keeps focus in the filter field with the Navigation API integration. `focusReset` isn't
168+
// in the router's public types on this branch, but the router reads it.
169+
focusReset: 'manual',
170+
} as NavigationExtras);
168171
});
169172
}
170173

0 commit comments

Comments
 (0)