Skip to content

Commit 8e82a1f

Browse files
committed
refactor(multiple): use afterNextRender for setDefaultState across all aria directives
1 parent d6929f1 commit 8e82a1f

File tree

5 files changed

+12
-17
lines changed

5 files changed

+12
-17
lines changed

src/aria/grid/grid.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*/
88

99
import {
10+
afterNextRender,
1011
afterRenderEffect,
1112
booleanAttribute,
1213
computed,
@@ -151,7 +152,7 @@ export class Grid {
151152
});
152153

153154
// Use Write mode for all direct DOM focus management actions.
154-
afterRenderEffect({write: () => this._pattern.setDefaultStateEffect()});
155+
afterNextRender({write: () => this._pattern.setDefaultStateEffect()});
155156
afterRenderEffect({write: () => this._pattern.resetStateEffect()});
156157
afterRenderEffect({write: () => this._pattern.resetFocusEffect()});
157158
afterRenderEffect({write: () => this._pattern.restoreFocusEffect()});

src/aria/listbox/listbox.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*/
88

99
import {
10+
afterNextRender,
1011
afterRenderEffect,
1112
booleanAttribute,
1213
computed,
@@ -158,6 +159,8 @@ export class Listbox<V> {
158159
this._popup._controls.set(this._pattern as ComboboxListboxPattern<V>);
159160
}
160161

162+
afterNextRender({write: () => this._pattern.setDefaultState()});
163+
161164
afterRenderEffect(() => {
162165
if (typeof ngDevMode === 'undefined' || ngDevMode) {
163166
const violations = this._pattern.validate();
@@ -167,10 +170,6 @@ export class Listbox<V> {
167170
}
168171
});
169172

170-
afterRenderEffect(() => {
171-
this._pattern.setDefaultStateEffect();
172-
});
173-
174173
// Ensure that if the active item is removed from
175174
// the list, the listbox updates it's focus state.
176175
afterRenderEffect(() => {

src/aria/menu/menu-bar.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
import {
10-
afterRenderEffect,
10+
afterNextRender,
1111
booleanAttribute,
1212
computed,
1313
contentChildren,
@@ -123,9 +123,7 @@ export class MenuBar<V> {
123123
element: computed(() => this._elementRef.nativeElement),
124124
});
125125

126-
afterRenderEffect(() => {
127-
this._pattern.setDefaultStateEffect();
128-
});
126+
afterNextRender({write: () => this._pattern.setDefaultState()});
129127
}
130128

131129
/** Closes the menubar. */

src/aria/tabs/tab-list.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
import {Directionality} from '@angular/cdk/bidi';
1010
import {
11+
afterNextRender,
12+
afterRenderEffect,
1113
booleanAttribute,
1214
computed,
1315
Directive,
@@ -16,7 +18,6 @@ import {
1618
input,
1719
model,
1820
signal,
19-
afterRenderEffect,
2021
OnInit,
2122
OnDestroy,
2223
} from '@angular/core';
@@ -118,9 +119,7 @@ export class TabList implements OnInit, OnDestroy {
118119
});
119120

120121
constructor() {
121-
afterRenderEffect(() => {
122-
this._pattern.setDefaultStateEffect();
123-
});
122+
afterNextRender({write: () => this._pattern.setDefaultState()});
124123

125124
afterRenderEffect(() => {
126125
const tab = this._pattern.selectedTab();

src/aria/toolbar/toolbar.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
import {
10-
afterRenderEffect,
10+
afterNextRender,
1111
Directive,
1212
ElementRef,
1313
inject,
@@ -106,9 +106,7 @@ export class Toolbar<V> {
106106
});
107107

108108
constructor() {
109-
afterRenderEffect(() => {
110-
this._pattern.setDefaultStateEffect();
111-
});
109+
afterNextRender({write: () => this._pattern.setDefaultState()});
112110
}
113111

114112
_register(widget: ToolbarWidget<V>) {

0 commit comments

Comments
 (0)