Skip to content

Commit 997e387

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

File tree

6 files changed

+18
-19
lines changed

6 files changed

+18
-19
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>) {

src/aria/tree/tree.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import {
1010
Directive,
1111
ElementRef,
12+
afterNextRender,
1213
afterRenderEffect,
1314
booleanAttribute,
1415
computed,
@@ -180,8 +181,11 @@ export class Tree<V> {
180181
}
181182
});
182183

183-
afterRenderEffect(() => {
184-
this._pattern.setDefaultStateEffect();
184+
// Resets default focus based on selection state until interacted.
185+
afterRenderEffect({
186+
write: () => {
187+
this._pattern.setDefaultStateEffect();
188+
},
185189
});
186190

187191
afterRenderEffect(() => {

0 commit comments

Comments
 (0)