Skip to content

Commit 9376e20

Browse files
committed
tweaks
1 parent 78d3aad commit 9376e20

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed

src/aria/accordion/accordion.ts

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -235,33 +235,46 @@ export class AccordionGroup {
235235
});
236236
}
237237

238-
/** Opens the specified item. */
238+
/** Opens the accordion panel with the specified value. */
239239
open(itemValue: string) {
240-
this._pattern.expansionManager.open(this._patternForValue(itemValue)!);
240+
const trigger = this._findTriggerPatternByValue(itemValue);
241+
242+
if (trigger) {
243+
this._pattern.expansionManager.open(trigger);
244+
}
241245
}
242246

243-
/** Closes the specified item. */
247+
/** Closes the accordion panel with the specified value. */
244248
close(itemValue: string) {
245-
this._pattern.expansionManager.close(this._patternForValue(itemValue)!);
249+
const trigger = this._findTriggerPatternByValue(itemValue);
250+
251+
if (trigger) {
252+
this._pattern.expansionManager.close(trigger);
253+
}
246254
}
247255

248-
/** Toggles the expansion state of the specified item. */
256+
/** Toggles the expansion state of the accordion panel with the specified value. */
249257
toggle(itemValue: string) {
250-
this._pattern.expansionManager.toggle(this._patternForValue(itemValue)!);
258+
const trigger = this._findTriggerPatternByValue(itemValue);
259+
260+
if (trigger) {
261+
this._pattern.expansionManager.toggle(trigger);
262+
}
251263
}
252264

253-
/** Opens all focusable items in the list. */
265+
/** Opens all accordion panels if multi-expandable. */
254266
openAll() {
255267
this._pattern.expansionManager.openAll();
256268
}
257269

258-
/** Closes all focusable items in the list. */
270+
/** Closes all accordion panels. */
259271
closeAll() {
260272
this._pattern.expansionManager.closeAll();
261273
}
262274

263-
_patternForValue(value: string) {
275+
_findTriggerPatternByValue(value: string) {
264276
const trigger = this._triggers().find(t => t.value() === value);
277+
265278
return trigger?._pattern;
266279
}
267280
}

0 commit comments

Comments
 (0)