Add modal backdrop-close, scroll-lock and dropdown placement rules

modal-workflows 1.3: a backdrop close needs the press and the release on the
backdrop; the page behind an open modal does not scroll.
controls-selection 1.4: dropdowns open upward when there is no room below and
never leave the viewport.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Mikhail ChusavitinandClaude Opus 5.5 committed 2026-10-02 17:01:12 +03:00
1 parent 577aa20fe3
commit 714447aa06
2 files changed
+26 -2

No files matched your search

+11 -1
View File
@@ -1,6 +1,6 @@
# Contract: Modal Workflows
Version: 1.1
Version: 1.3
## State Machine
@@ -26,6 +26,16 @@ closed → open → submitting → success | error
- Submit button text must describe the action: "Save", "Delete", "Archive" — not "OK" or "Confirm".
- Modal title must match the action: "Edit Component", "Delete Asset" — not generic "Modal".
- Escape key and clicking the backdrop close the modal (unless in `submitting` state).
- A backdrop close requires the whole click on the backdrop: the pointer must go down AND come
up on it. A press that starts inside the dialog (selecting text in an input, dragging a slider
or scrollbar) and is released outside it must NOT close the modal. A bare
`click` handler with `event.target === backdrop` is not enough: the browser fires `click` on
the common ancestor of the press and release targets, which is the backdrop. Record the
`pointerdown`/`mousedown` target and close only when it is the backdrop too.
- Implement this once, in shared modal code that covers every modal in the app, not per modal.
- While a modal is open the page behind it must not scroll. Wheel, touch and keyboard scrolling
move the dialog only, and reaching the dialog's end must not chain to the page. Reserve the
scrollbar gutter so locking the page does not shift the layout under the backdrop.
## Validation