Skip to content

[Feature][Medium] Fix engagement zone rotation stacking, modal lifecycle bugs, and outdated Rollup #97

@numbers-official

Description

@numbers-official

Summary

Three related code quality and bug findings that affect widget reliability and maintainability:

1. Engagement Zone Rotation Intervals Can Stack (Bug)

File: src/modal/modal.ts, lines 173-179, 224-227

startEngagementZoneRotation() calls setInterval without first clearing any existing interval. handleImageLoad() (line 224) calls startEngagementZoneRotation() without calling stopEngagementZoneRotation() first. If preloadEngagementZoneImages() is called multiple times (via updateModalOptions, line 140), multiple intervals stack, causing increasingly rapid rotation.

Fix: Call stopEngagementZoneRotation() at the beginning of startEngagementZoneRotation().

2. Body Click Handler May Inadvertently Recreate Modal

File: src/modal/modal-manager.ts, lines 93-98

handleRootClick calls this.getModal() which creates a new modal element if one does not exist. Clicking anywhere on the body after modal removal could inadvertently recreate it.

Fix: Use this.modalElement directly with a null check instead of this.getModal():

private handleRootClick = (event: MouseEvent) => {
  if (this.modalElement && !this.modalElement.contains(event.target as Node)) {
    this.removeModal();
  }
};

3. Rollup v2 is Outdated and No Longer Receiving Security Patches

File: package.json, line 62

"rollup": "^2.73.0" — Rollup v2 has been superseded by v4 (stable since late 2023). V2 no longer receives security patches. Several plugins are also at outdated major versions.

Fix: Upgrade to Rollup v4 along with compatible plugin versions (@rollup/plugin-node-resolve, @rollup/plugin-terser, etc.).

Expected Impact

  • Prevents engagement zone carousel from accelerating unexpectedly
  • Eliminates accidental modal recreation on stray body clicks
  • Gains better tree-shaking, faster builds, and security patches via Rollup v4

References

Generated by Heart Beat with Omni

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions