Skip to content

[Catalog] Fix DOMContentLoaded lifecycle issue in dynamically loaded catalog modal scripts #2761

Description

@ananyaa0518

Description

catalog-modal.js relies on the DOMContentLoaded event for initialization. However, this script is dynamically loaded after the page has already finished loading through _includes/modal.html.

As a result, the DOMContentLoaded callback never executes, preventing the "Read More" initialization logic from running for dynamically loaded modal content.

Expected Behavior

The initialization logic should execute regardless of whether the script is loaded before or after the DOMContentLoaded event.

A possible solution is to use document.readyState and initialize immediately if the document has already loaded.

Screenshots

N/A (JavaScript lifecycle issue)

Environment:

  • OS: macOS
  • Browser: Chrome
  • Version: Latest
  • Device: Desktop

Metadata

Metadata

Assignees

Labels

help wantedExtra attention is neededkind/bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions