Skip to content

Commit d6a3ec2

Browse files
committed
refactor(aria/tree): Change afterRenderEffect to use write stage and effect appropriately
1 parent e0a2813 commit d6a3ec2

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

src/aria/tree/tree.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
afterRenderEffect,
1313
booleanAttribute,
1414
computed,
15+
effect,
1516
inject,
1617
input,
1718
model,
@@ -170,7 +171,7 @@ export class Tree<V> {
170171
this._popup?._controls?.set(this._pattern as ComboboxTreePattern<V>);
171172
}
172173

173-
afterRenderEffect(() => {
174+
effect(() => {
174175
if (typeof ngDevMode === 'undefined' || ngDevMode) {
175176
const violations = this._pattern.validate();
176177
for (const violation of violations) {
@@ -182,16 +183,18 @@ export class Tree<V> {
182183
// Resets default focus based on selection state until interacted.
183184
afterRenderEffect({write: () => this._pattern.setDefaultStateEffect()});
184185

185-
afterRenderEffect(() => {
186-
const items = inputs.items();
187-
const activeItem = untracked(() => inputs.activeItem());
186+
afterRenderEffect({
187+
write: () => {
188+
const items = inputs.items();
189+
const activeItem = untracked(() => inputs.activeItem());
188190

189-
if (!items.some(i => i === activeItem) && activeItem) {
190-
this._pattern.treeBehavior.unfocus();
191-
}
191+
if (!items.some(i => i === activeItem) && activeItem) {
192+
this._pattern.treeBehavior.unfocus();
193+
}
194+
},
192195
});
193196

194-
afterRenderEffect(() => {
197+
effect(() => {
195198
if (!(this._pattern instanceof ComboboxTreePattern)) return;
196199

197200
const items = inputs.items();

0 commit comments

Comments
 (0)