diff --git a/docs/assets/js/ColorSelect.js b/docs/assets/js/ColorSelect.js index b5d231fe4f..12e6e4c49d 100644 --- a/docs/assets/js/ColorSelect.js +++ b/docs/assets/js/ColorSelect.js @@ -111,13 +111,18 @@ function handleDelete(slot) { startFlashingRed(slot); }, 500); // Start flashing red after holding for 500ms - document.querySelector(`[data-slot="${slot}"]`).addEventListener('mouseup', () => { + const slotElement = document.querySelector(`[data-slot="${slot}"]`); + + const onMouseUp = () => { clearTimeout(holdTimer); if (deleteMode) { deleteColor(slot); // Delete the color if it's flashing red stopFlashingRed(slot); } - }); + document.removeEventListener('mouseup', onMouseUp); // Ensure the event listener is removed + }; + + slotElement.addEventListener('mouseup', onMouseUp, { once: true }); // Attach the event listener to the slot } function showHueQuadrantDropdown(slot) {