@@ -152,16 +152,10 @@ export class CdkTab {
152152 private readonly _cdkTablist = inject ( CdkTablist ) ;
153153
154154 /** A unique identifier for the tab. */
155- private readonly _generatedId = inject ( _IdGenerator ) . getId ( 'cdk-tab-' ) ;
156-
157- /** A unique identifier for the tab. */
158- protected id = computed ( ( ) => this . _generatedId ) ;
159-
160- /** A reference to the tab element to be focused on navigation. */
161- protected element = computed ( ( ) => this . _elementRef . nativeElement ) ;
155+ private readonly _id = inject ( _IdGenerator ) . getId ( 'cdk-tab-' ) ;
162156
163157 /** The position of the tab in the list. */
164- protected index = computed ( ( ) => this . _cdkTabs . tabs ( ) . findIndex ( tab => tab . id === this . id ) ) ;
158+ protected index = computed ( ( ) => this . _cdkTabs . tabs ( ) . findIndex ( tab => tab . id ( ) === this . _id ) ) ;
165159
166160 /** The parent Tablist UIPattern. */
167161 protected tablist = computed ( ( ) => this . _cdkTablist . pattern ) ;
@@ -175,14 +169,21 @@ export class CdkTab {
175169 /** The Tab UIPattern. */
176170 pattern : TabPattern = new TabPattern ( {
177171 ...this ,
178- id : this . id ,
172+ id : ( ) => this . _id ,
173+ element : ( ) => this . _elementRef . nativeElement ,
179174 tablist : this . tablist ,
180175 tabpanel : this . tabpanel ,
181- element : this . element ,
182176 } ) ;
183177}
184178
185- /** A Tabpanel container for the resources of layered content associated with a tab. */
179+ /**
180+ * A Tabpanel container for the resources of layered content associated with a tab.
181+ *
182+ * If a tabpanel is hidden due to its corresponding tab is not activated, the `inert` attribute
183+ * will be applied to the tabpanel element to remove it from the accessibility tree and stop
184+ * all the keyboard and pointer interactions. Note that this does not visually hide the tabpenl
185+ * and a proper styling is required.
186+ */
186187@Directive ( {
187188 selector : '[cdkTabpanel]' ,
188189 exportAs : 'cdkTabpanel' ,
@@ -198,14 +199,11 @@ export class CdkTabpanel {
198199 private readonly _cdkTabs = inject ( CdkTabs ) ;
199200
200201 /** A unique identifier for the tab. */
201- private readonly _generatedId = inject ( _IdGenerator ) . getId ( 'cdk-tabpanel-' ) ;
202-
203- /** A unique identifier for the tabpanel. */
204- protected id = computed ( ( ) => this . _generatedId ) ;
202+ private readonly _id = inject ( _IdGenerator ) . getId ( 'cdk-tabpanel-' ) ;
205203
206204 /** The position of the tabpanel in the tabs. */
207205 protected index = computed ( ( ) =>
208- this . _cdkTabs . tabpanels ( ) . findIndex ( tabpanel => tabpanel . id === this . id ) ,
206+ this . _cdkTabs . tabpanels ( ) . findIndex ( tabpanel => tabpanel . id ( ) === this . _id ) ,
209207 ) ;
210208
211209 /** The Tab UIPattern associated with the tabpanel */
@@ -214,7 +212,7 @@ export class CdkTabpanel {
214212 /** The Tabpanel UIPattern. */
215213 pattern : TabpanelPattern = new TabpanelPattern ( {
216214 ...this ,
217- id : this . id ,
215+ id : ( ) => this . _id ,
218216 tab : this . tab ,
219217 } ) ;
220218}
0 commit comments