Skip to content

Commit

Permalink
feat(Accordion): use common id generator closes #508
Browse files Browse the repository at this point in the history
  • Loading branch information
ValentinNelu authored and quentinderoubaix committed Feb 27, 2024
1 parent 069667c commit 4d6ff33
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions core/src/components/accordion/accordion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,7 @@ import {noop} from '../../utils/internal/func';
import type {WidgetsCommonPropsAndState} from '../commonProps';
import {typeBoolean, typeFunction, typeString} from '../../utils/writables';
import {bindDirectiveNoArg, directiveSubscribe, registrationArray} from '../../utils/directive';

let itemId = 0;

function getItemId() {
return `accordion-item-${itemId++}`;
}
import {generateId} from '../../utils/internal/dom';

function adjustItemsCloseOthers(items: AccordionItemWidget[], openItems: string[], oldOpen?: string): AccordionItemWidget[] {
let keepOpen: undefined | string;
Expand Down Expand Up @@ -483,7 +478,7 @@ function createAccordionItem(
] = writablesForProps(defaultItemConfig, config, configItemValidator);

const initDone$ = writable(false);
const _autoItemId$ = computed(() => getItemId());
const _autoItemId$ = computed(() => generateId());
const itemId$ = computed(() => _dirtyItemId$() || _autoItemId$());
const shouldBeInDOM$ = computed(() => itemDestroyOnHide$() === false || !itemTransition.state$().hidden);
const itemTransition = createTransition({
Expand Down

0 comments on commit 4d6ff33

Please sign in to comment.