The module-level galleryState kept activeIndex/expanded across models (the modal is a singleton), so opening model B after navigating model A started B's gallery at A's last index. Reset activeIndex, expanded and lastNavDirection in loadExampleImages, the per-model entry point.