Skip to content

Commit

Permalink
fix(flow): process items on loaded (#11364)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcfranco authored Jan 23, 2025
1 parent 62b4902 commit 93e5ff2
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions packages/calcite-components/src/components/flow/flow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ export class Flow extends LitElement implements LoadableComponent {
private frameEl: HTMLDivElement;

private itemMutationObserver: MutationObserver = createObserver("mutation", () =>
this.handleMutationObserverChange(),
this.updateItemsAndProps(),
);

private items: FlowItemLikeElement[] = [];

private selectedIndex = -1;

// #endregion
Expand All @@ -44,8 +46,6 @@ export class Flow extends LitElement implements LoadableComponent {

@state() flowDirection: FlowDirection = "standby";

@state() items: FlowItemLikeElement[] = [];

// #endregion

// #region Public Properties
Expand Down Expand Up @@ -120,7 +120,6 @@ export class Flow extends LitElement implements LoadableComponent {

override connectedCallback(): void {
this.itemMutationObserver?.observe(this.el, { childList: true, subtree: true });
this.handleMutationObserverChange();
}

load(): void {
Expand All @@ -139,6 +138,7 @@ export class Flow extends LitElement implements LoadableComponent {

loaded(): void {
setComponentLoaded(this);
this.updateItemsAndProps();
}

override disconnectedCallback(): void {
Expand Down Expand Up @@ -194,7 +194,7 @@ export class Flow extends LitElement implements LoadableComponent {
return newSelectedIndex < oldSelectedIndex ? "retreating" : "advancing";
}

private handleMutationObserverChange(): void {
private updateItemsAndProps(): void {
const { customItemSelectors, el } = this;

const newItems = Array.from<FlowItemLikeElement>(
Expand All @@ -206,7 +206,6 @@ export class Flow extends LitElement implements LoadableComponent {
this.items = newItems;

this.ensureSelectedFlowItemExists();

this.updateFlowProps();
}

Expand Down

0 comments on commit 93e5ff2

Please sign in to comment.