Skip to content

Conversation

@severe77
Copy link
Contributor

Description

This PR fixes an issue where the palette outside-click listener was not always
cleaned up correctly when palettes were opened and closed repeatedly.

Previously, the listener was attached using a deferred setTimeout, which could
result in stale document.click listeners being added after the palette lifecycle
had already changed. Over time, this caused listener accumulation and memory growth
during long-running sessions.

The listener lifecycle is now fully deterministic and properly cleaned up.

Changes

  • Removed deferred (setTimeout) attachment of the outside-click listener
  • Ensured any existing outside-click listener is removed before adding a new one
  • Cleaned up the listener immediately when the palette is closed
  • Added a null-safe guard for menuContainer to prevent edge-case errors
  • Kept the fix scoped strictly to js/palette.js

Notes

  • Change is limited to outside-click listener lifecycle cleanup
  • No functional behavior changes expected
  • All Jest tests passed locally

Fixes #5362

@github-actions
Copy link
Contributor

✅ All Jest tests passed! This PR is ready to merge.

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.

[Bug] Palette outside-click listener not cleaned up on close

1 participant