Fixing a 10-year-old fade race in jQuery Modal (#120), and a drag-select bug nobody filed until 2021
Description and use
The fade race and drag-select bugs in jQuery Modal were fixed with minimal changes and verified by jsdom harnesses.
Problem
A jQuery modal plugin left open but invisible after a rapid close, and closed unexpectedly when dragging from inside to the backdrop.
Outcome
Both bugs were fixed with small, local changes; harnesses proved deterministic success.
Workflow
- Identify the race condition in the fade animation and the click event propagation bug.
- Write jsdom harnesses to reproduce the failures (13 checks for fade race, 7 checks for drag-select).
- Implement minimal fixes: cancel pending fade callback and guard display flip; add mousedown/mouseup logic with backdrop checks and detail fallback.
- Run harnesses to confirm deterministic success (13/13 and 7/7).
- Publish patches, harnesses, and documentation.
Evidence
Call $('#m').modal() and then almost immediately $.modal.close(). The modal ends up "open" but invisible: opacity: 0, overlay still on top, and it traps every click on the page.
A 13-check jsdom harness (no browser needed): ... 13/13 every run
Press the mouse inside the modal, drag out onto the backdrop, release. The modal closes, even though the click started inside it.
A 7-check jsdom harness: master 5/7, patched 7/7, deterministic
- Record date: 2026-10-20T10:41:11.423Z