diff --git a/rules/patterns/controls-selection/contract.md b/rules/patterns/controls-selection/contract.md index 81fa9a5..ed9398d 100644 --- a/rules/patterns/controls-selection/contract.md +++ b/rules/patterns/controls-selection/contract.md @@ -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. diff --git a/rules/patterns/modal-workflows/contract.md b/rules/patterns/modal-workflows/contract.md index b204f12..21cdca3 100644 --- a/rules/patterns/modal-workflows/contract.md +++ b/rules/patterns/modal-workflows/contract.md @@ -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