@@ -38,6 +38,7 @@ import {ExampleViewer} from '../example-viewer/example-viewer';
3838import { HeaderLink } from './header-link' ;
3939import { DeprecatedFieldComponent } from './deprecated-tooltip' ;
4040import { ModuleImportCopyButton } from './module-import-copy-button' ;
41+ import { AngularAriaBanner } from './angular-aria-banner/angular-aria-banner' ;
4142
4243@Injectable ( { providedIn : 'root' } )
4344class DocFetcher {
@@ -154,6 +155,9 @@ export class DocViewer implements OnDestroy {
154155 this . _loadComponents ( 'material-docs-example' , ExampleViewer ) ;
155156 this . _loadComponents ( 'header-link' , HeaderLink ) ;
156157
158+ // Inject Angular Aria banner for specific CDK components
159+ this . _injectAngularAriaBanner ( ) ;
160+
157161 // Create tooltips for the deprecated fields
158162 this . _createTooltipsForDeprecated ( ) ;
159163
@@ -267,4 +271,37 @@ export class DocViewer implements OnDestroy {
267271 this . _portalHosts . push ( elementPortalOutlet ) ;
268272 } ) ;
269273 }
274+
275+ /**
276+ * Injects the Angular Aria migration banner for specific CDK components.
277+ */
278+ private _injectAngularAriaBanner ( ) {
279+ const componentName = this . name ( ) ;
280+ const componentsWithAriaBanner = [ 'listbox' , 'tree' , 'accordion' , 'menu' ] ;
281+
282+ if ( ! componentName || ! componentsWithAriaBanner . includes ( componentName . toLowerCase ( ) ) ) {
283+ return ;
284+ }
285+
286+ // Create a container div for the banner at the beginning of the document
287+ const bannerContainer = document . createElement ( 'div' ) ;
288+ bannerContainer . setAttribute ( 'angular-aria-banner' , '' ) ;
289+ bannerContainer . setAttribute ( 'componentName' , componentName ) ;
290+
291+ // Insert the banner at the beginning of the document content
292+ const firstChild = this . _elementRef . nativeElement . firstChild ;
293+ if ( firstChild ) {
294+ this . _elementRef . nativeElement . insertBefore ( bannerContainer , firstChild ) ;
295+ } else {
296+ this . _elementRef . nativeElement . appendChild ( bannerContainer ) ;
297+ }
298+
299+ // Create and attach the banner component
300+ const portalHost = new DomPortalOutlet ( bannerContainer , this . _appRef , this . _injector ) ;
301+ const bannerPortal = new ComponentPortal ( AngularAriaBanner , this . _viewContainerRef ) ;
302+ const bannerComponent = portalHost . attach ( bannerPortal ) ;
303+ bannerComponent . instance . componentName = componentName ;
304+
305+ this . _portalHosts . push ( portalHost ) ;
306+ }
270307}
0 commit comments