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

+15 -1
View File
@@ -1,6 +1,6 @@
# Contract: Controls + Selection
Version: 1.3
Version: 1.4
## Shared Base
@@ -28,6 +28,20 @@ Version: 1.3
other in-page element. Use a `button` (or button-styled control) instead, unless the user
explicitly asks for a hyperlink. Hyperlinks are reserved for navigation to another URL/page.
## Dropdowns and Popups
Applies to every floating panel anchored to a control: autocomplete/combobox lists, custom
selects, multiselect filters, menus, date pickers.
- A panel opens below its control by default. When it does not fit below and there is more room
above, it opens upward. Decide on every open and on scroll/resize while open, from the control's
actual position in the viewport; never hardcode a direction.
- A panel must never extend past the viewport edge. If it fits neither way, cap its height to the
room available on the chosen side and let it scroll.
- A panel must not be clipped by an ancestor's `overflow` (modal body, table wrapper). Position it
against the viewport (`position: fixed` or a body-level layer), not inside the clipping container.
- Implement placement once in the shared dropdown code; do not re-derive it per control.
## Checkbox Selection
- Row checkboxes support bulk actions from a shared action bar.
+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