Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 20, 2025

The atomic-search-interface initialization could complete before all child components (particularly dynamically loaded ones) were fully defined, causing incomplete state or runtime errors when child components like atomic-facet loaded asynchronously.

Changes

  • Added waitForAllVanillaChildrenComponentsToBeDefined() method in atomic-search-interface.ts
    • Queries all child elements with tags starting with ATOMIC-
    • Uses customElements.whenDefined() to wait for each component definition
    • Called during internalInitialization() after bindings setup but before URL manager initialization

Implementation

private async waitForAllVanillaChildrenComponentsToBeDefined() {
  await Promise.all(
    Array.from(this.querySelectorAll('*'))
      .filter((el) => el.tagName.startsWith('ATOMIC-'))
      .map((el) => customElements.whenDefined(el.tagName.toLowerCase()))
  );
}

This ensures that when a facet or other child component's JavaScript is delayed (network latency, code splitting, etc.), initialization will properly wait rather than proceeding with undefined components.

Testing

Create an HTML page with a custom delayed component to verify:

setTimeout(() => {
  customElements.define('atomic-custom-facet', AtomicCustomFacet);
}, 2000);

const interface = document.getElementById('interface');
await interface.initialize(config); // Will wait ≥2000ms for custom component

Without this fix, initialization completes in <100ms and may fail or have incomplete state.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Fix initialization of vanilla children components fix: ensure atomic-search-interface waits for all child components to be defined before completing initialization Nov 20, 2025
Copilot AI requested a review from louis-bompart November 20, 2025 05:34
Copilot finished work on behalf of louis-bompart November 20, 2025 05:34
Base automatically changed from fix/KIT-5249 to main November 20, 2025 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants