@capagents/forgeqe 3.1.0 → 3.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (254) hide show
  1. package/HOW_TO_USE.md +465 -95
  2. package/README.md +21 -6
  3. package/THIRD_PARTY_NOTICES.md +210 -1
  4. package/dist/docs-site/CREDITS.md +6 -0
  5. package/dist/docs-site/architecture-map/index.html +1 -1
  6. package/dist/docs-site/docs/app-theme.css +100 -8
  7. package/dist/docs-site/docs/architecture/index.html +210 -214
  8. package/dist/docs-site/docs/area-api/index.html +350 -0
  9. package/dist/docs-site/docs/area-automated-tests/index.html +967 -0
  10. package/dist/docs-site/docs/area-browser/index.html +430 -0
  11. package/dist/docs-site/docs/area-data/index.html +605 -0
  12. package/dist/docs-site/docs/area-desktop/index.html +755 -0
  13. package/dist/docs-site/docs/area-mobile/index.html +631 -0
  14. package/dist/docs-site/docs/area-operations/index.html +1069 -0
  15. package/dist/docs-site/docs/area-pull-requests/index.html +208 -0
  16. package/dist/docs-site/docs/area-quality/index.html +365 -0
  17. package/dist/docs-site/docs/area-release/index.html +320 -0
  18. package/dist/docs-site/docs/area-setup/index.html +1192 -0
  19. package/dist/docs-site/docs/area-systems/index.html +207 -0
  20. package/dist/docs-site/docs/area-test-cases/index.html +694 -0
  21. package/dist/docs-site/docs/containers/index.html +97 -104
  22. package/dist/docs-site/docs/cost-architecture/index.html +108 -112
  23. package/dist/docs-site/docs/custom-agents-first-run/index.html +19 -23
  24. package/dist/docs-site/docs/desktop/index.html +172 -162
  25. package/dist/docs-site/docs/desktop-ci/index.html +26 -33
  26. package/dist/docs-site/docs/evidence/index.html +253 -257
  27. package/dist/docs-site/docs/feature-test-prompts/index.html +66 -70
  28. package/dist/docs-site/docs/get-started/index.html +495 -0
  29. package/dist/docs-site/docs/graphify/index.html +42 -46
  30. package/dist/docs-site/docs/guardrails/index.html +17 -21
  31. package/dist/docs-site/docs/index.html +17 -6708
  32. package/dist/docs-site/docs/mobile/index.html +155 -162
  33. package/dist/docs-site/docs/model-routing/index.html +44 -51
  34. package/dist/docs-site/docs/overview/index.html +176 -0
  35. package/dist/docs-site/docs/product-graph/index.html +52 -55
  36. package/dist/docs-site/docs/product-knowledge/index.html +11 -15
  37. package/dist/docs-site/docs/product-views/index.html +53 -57
  38. package/dist/docs-site/docs/reference/index.html +379 -0
  39. package/dist/docs-site/docs/search.js +1 -1
  40. package/dist/docs-site/docs/using/index.html +480 -0
  41. package/dist/docs-site/docs/web-app/index.html +147 -93
  42. package/dist/docs-site/security/index.html +930 -0
  43. package/dist/docs-site/security/security-theme.css +161 -0
  44. package/dist/docs-site/security/security.js +1465 -0
  45. package/dist/docs-site/vendor/react-18.3.1.production.min.js +31 -0
  46. package/dist/docs-site/vendor/react-dom-18.3.1.production.min.js +267 -0
  47. package/dist/docs-site/vendor/reactflow-11.11.4.umd.js +10 -0
  48. package/dist/forgeqe.js +2251 -1886
  49. package/dist/web/THIRD_PARTY_NOTICES.md +0 -136
  50. package/dist/web/assets/Agent-CPhmZdFX.js +8 -0
  51. package/dist/web/assets/AgentWork-BXdN9xgi.js +2 -0
  52. package/dist/web/assets/ApiTests-Do3xLjfB.js +10 -0
  53. package/dist/web/assets/Browse-WVkJT6Bs.js +2 -0
  54. package/dist/web/assets/Chat-CDc9UcQX.js +3 -0
  55. package/dist/web/assets/CommandPalette-BAZm62lV.js +1 -0
  56. package/dist/web/assets/Compare-Br6n9T9L.js +1 -0
  57. package/dist/web/assets/Cost-BBUyBu3Y.js +1 -0
  58. package/dist/web/assets/Data-Ch2DPEWp.js +6 -0
  59. package/dist/web/assets/Desktop-Qzoq-cQv.js +1 -0
  60. package/dist/web/assets/DesktopReview-CF_jQYAM.js +1 -0
  61. package/dist/web/assets/Evidence-C72Lj5_Q.js +1 -0
  62. package/dist/web/assets/Explore-ObkEpUyS.js +2 -0
  63. package/dist/web/assets/Features-CQzNo_WP.js +1 -0
  64. package/dist/web/assets/Flags-0-RniPJm.js +2 -0
  65. package/dist/web/assets/Flaky-BPJvNLCA.js +1 -0
  66. package/dist/web/assets/Impact-CfccsL_k.js +3 -0
  67. package/dist/web/assets/Jobs-T6m4zhDy.js +5 -0
  68. package/dist/web/assets/KindPage-BDUvWe2p.js +6 -0
  69. package/dist/web/assets/Migration-Dqeh4x5u.js +2 -0
  70. package/dist/web/assets/PageAgent-DNjzIgeY.js +1 -0
  71. package/dist/web/assets/Product-nYV_scOV.js +7 -0
  72. package/dist/web/assets/Production-CGSbEWVa.js +1 -0
  73. package/dist/web/assets/Quality-BIypojZm.js +1 -0
  74. package/dist/web/assets/Readiness-BlRjwJRg.js +1 -0
  75. package/dist/web/assets/Record-v2KLI-_Z.js +1 -0
  76. package/dist/web/assets/Regression-B-jSt4Jz.js +5 -0
  77. package/dist/web/assets/RelationGraph-8J98lOVG.js +1 -0
  78. package/dist/web/assets/Reports-GI4u6SyW.js +2 -0
  79. package/dist/web/assets/Response-mhBThq2b.js +9 -0
  80. package/dist/web/assets/Responsive-DXu7Ra7K.js +3 -0
  81. package/dist/web/assets/RunDiff-D0SHDNp0.js +1 -0
  82. package/dist/web/assets/Runs-C1Gjdi9M.js +2 -0
  83. package/dist/web/assets/Settings-BGGeuvyF.js +21 -0
  84. package/dist/web/assets/Steps-D-YG0eJy.js +2 -0
  85. package/dist/web/assets/TestCases-DC4w77eQ.js +1 -0
  86. package/dist/web/assets/TestData-CvKWRVVV.js +2 -0
  87. package/dist/web/assets/TestDebt-D8YzN29_.js +1 -0
  88. package/dist/web/assets/TestManagement-C5cDCqrD.js +1 -0
  89. package/dist/web/assets/Tosca-BGUv3RiJ.js +3 -0
  90. package/dist/web/assets/WhatsNew-B_Gyuv8O.js +1 -0
  91. package/dist/web/assets/agents-C0Jg2pN8.js +1 -0
  92. package/dist/web/assets/coverage-BMP6ELFJ.js +5 -0
  93. package/dist/web/assets/dataParts-DbeCj9ga.js +3 -0
  94. package/dist/web/assets/diff-BStuTmsN.js +2 -0
  95. package/dist/web/assets/families-BBFFrUlo.js +1 -0
  96. package/dist/web/assets/filters-CnAMr286.js +1 -0
  97. package/dist/web/assets/fold-D_O_VZui.js +1 -0
  98. package/dist/web/assets/head-CRo48rPt.js +1 -0
  99. package/dist/web/assets/highlight-BcFZIf59.js +4 -0
  100. package/dist/web/assets/index-B3JsM7tv.js +64 -0
  101. package/dist/web/assets/index-CafApcbZ.css +2 -0
  102. package/dist/web/assets/input-CtzK50ZF.js +1 -0
  103. package/dist/web/assets/jsx-runtime-LKYXHABd.js +1 -0
  104. package/dist/web/assets/line-icons-rdF8DYDJ.js +1 -0
  105. package/dist/web/assets/logos-D4oVWzqa.js +1 -0
  106. package/dist/web/assets/palette-DAaGSao7.js +1 -0
  107. package/dist/web/assets/paletteCommands-Co-RlQ8q.js +1 -0
  108. package/dist/web/assets/parts-D357Wolo.js +1 -0
  109. package/dist/web/assets/productParts-B8oHRCJF.js +1 -0
  110. package/dist/web/assets/qualityParts-BLkmIfDY.js +1 -0
  111. package/dist/web/assets/recordTest-Cez2sDJO.js +1 -0
  112. package/dist/web/assets/rolldown-runtime-XKyaHtl9.js +1 -0
  113. package/dist/web/assets/route-BloYJWgw.js +1 -0
  114. package/dist/web/index.html +12 -12
  115. package/docs/ARCHITECTURE.md +1 -1
  116. package/docs/BASAL.md +1 -1
  117. package/docs/DESKTOP.md +20 -1
  118. package/docs/EVIDENCE.md +1 -1
  119. package/docs/MOBILE.md +4 -4
  120. package/docs/PRODUCT_KNOWLEDGE.md +2 -0
  121. package/docs/WEB_APP.md +114 -51
  122. package/docs/user-guide.html +463 -87
  123. package/forgeqe.example.yaml +3 -3
  124. package/package.json +1 -1
  125. package/prompts/page-differs.md +1 -1
  126. package/prompts/requests-rule.md +1 -1
  127. package/prompts/responsive-review.md +38 -0
  128. package/prompts/responsive-split.md +40 -0
  129. package/prompts/responsive.md +42 -0
  130. package/prompts/test-reviewer.md +1 -1
  131. package/prompts/test-rules.md +3 -4
  132. package/skills/web-guidance/LICENSE +202 -0
  133. package/skills/web-guidance/SKILL.md +76 -0
  134. package/skills/web-guidance/UPSTREAM +67 -0
  135. package/skills/web-guidance/references/accessibility/accessibility.md +585 -0
  136. package/skills/web-guidance/references/accessibility/accessible-error-announcement.md +302 -0
  137. package/skills/web-guidance/references/accessibility/accessible-generated-content.md +41 -0
  138. package/skills/web-guidance/references/accessibility/respect-os-text-scale.md +127 -0
  139. package/skills/web-guidance/references/css/responsive-design.md +16 -0
  140. package/skills/web-guidance/references/forms/autofill-address-form.md +86 -0
  141. package/skills/web-guidance/references/forms/autofill-payment-form.md +142 -0
  142. package/skills/web-guidance/references/forms/autofill-sign-in-form.md +145 -0
  143. package/skills/web-guidance/references/forms/autofill-sign-up-form.md +155 -0
  144. package/skills/web-guidance/references/forms/forms.md +415 -0
  145. package/skills/web-guidance/references/forms/ime-safe-enter-submit.md +115 -0
  146. package/skills/web-guidance/references/forms/required-field-feedback.md +317 -0
  147. package/skills/web-guidance/references/forms/select-menu-interaction.md +310 -0
  148. package/skills/web-guidance/references/forms/slider.md +184 -0
  149. package/skills/web-guidance/references/forms/sms-otp-form.md +208 -0
  150. package/skills/web-guidance/references/forms/switch.md +60 -0
  151. package/skills/web-guidance/references/forms/validate-input-after-interaction.md +406 -0
  152. package/skills/web-guidance/references/performance/break-up-long-tasks.md +64 -0
  153. package/skills/web-guidance/references/performance/identify-heavy-scripts.md +69 -0
  154. package/skills/web-guidance/references/performance/identify-inp-causes.md +105 -0
  155. package/skills/web-guidance/references/performance/interaction-paint-timing.md +200 -0
  156. package/skills/web-guidance/references/performance/optimize-image-priority.md +73 -0
  157. package/skills/web-guidance/references/performance/performance.md +384 -0
  158. package/skills/web-guidance/references/privacy/privacy.md +247 -0
  159. package/skills/web-guidance/references/security/passkey-authentication.md +218 -0
  160. package/skills/web-guidance/references/security/passkey-management.md +310 -0
  161. package/skills/web-guidance/references/security/passkey-reauthentication.md +142 -0
  162. package/skills/web-guidance/references/security/passkey-registration.md +186 -0
  163. package/skills/web-guidance/references/security/passkeys.md +39 -0
  164. package/skills/web-guidance/references/security/sanitize-untrusted-html.md +105 -0
  165. package/skills/web-guidance/references/security/secure-external-subresources.md +202 -0
  166. package/skills/web-guidance/references/security/security.md +390 -0
  167. package/skills/web-guidance/references/security/trusted-types.md +141 -0
  168. package/skills/web-guidance/references/security/validate-origins.md +197 -0
  169. package/skills/web-guidance/references/security/verify-email-ownership.md +235 -0
  170. package/skills/web-guidance/references/ui-atoms/position-aware-tooltips.md +173 -0
  171. package/skills/web-guidance/references/ui-atoms/responsive-table.md +122 -0
  172. package/skills/web-guidance/references/ui-atoms/viewport-aware-dropdowns.md +178 -0
  173. package/skills/web-guidance/references/ui-behaviors/drag-and-drop.md +108 -0
  174. package/skills/web-guidance/references/ui-behaviors/light-dismiss-a-dialog.md +89 -0
  175. package/skills/web-guidance/references/ui-behaviors/motion.md +97 -0
  176. package/skills/web-guidance/references/ui-behaviors/platform-controls-dismiss-dialog.md +40 -0
  177. package/skills/web-guidance/references/ui-behaviors/prevent-page-scroll-under-modal-dialog.md +59 -0
  178. package/skills/web-guidance/references/ui-behaviors/search-hidden-content.md +141 -0
  179. package/skills/web-guidance/references/ui-behaviors/sortable-table.md +140 -0
  180. package/skills/web-guidance/references/ui-components/accordion.md +343 -0
  181. package/skills/web-guidance/references/ui-components/breadcrumbs.md +168 -0
  182. package/skills/web-guidance/references/ui-components/carousel.md +206 -0
  183. package/skills/web-guidance/references/ui-components/checkbox.md +144 -0
  184. package/skills/web-guidance/references/ui-components/dialog.md +218 -0
  185. package/skills/web-guidance/references/ui-components/hovercard.md +391 -0
  186. package/skills/web-guidance/references/ui-components/menu.md +415 -0
  187. package/skills/web-guidance/references/ui-components/navbar.md +281 -0
  188. package/skills/web-guidance/references/ui-components/navigation-drawer.md +429 -0
  189. package/skills/web-guidance/references/ui-components/persistent-toast-notifications.md +185 -0
  190. package/skills/web-guidance/references/ui-components/progress.md +181 -0
  191. package/skills/web-guidance/references/ui-components/spinner.md +179 -0
  192. package/skills/web-guidance/references/ui-components/tabs.md +371 -0
  193. package/skills/web-guidance/references/ui-components/toolbar.md +277 -0
  194. package/skills/web-guidance/references/user-experience/form-factor-adaptation.md +120 -0
  195. package/skills/web-guidance/references/user-experience/natural-interactions.md +155 -0
  196. package/skills/web-guidance/references/visual-design/color.md +43 -0
  197. package/skills/web-guidance/references/visual-design/dark-mode.md +350 -0
  198. package/dist/web/assets/AgentWork-C3KdZh5M.js +0 -2
  199. package/dist/web/assets/ApiTests-BLnl7JGO.js +0 -10
  200. package/dist/web/assets/Browse-C-Enjpmd.js +0 -2
  201. package/dist/web/assets/Chat-Bt6jZI68.js +0 -3
  202. package/dist/web/assets/Choices-D5eTFinz.js +0 -3
  203. package/dist/web/assets/CommandPalette-D89NM2_E.js +0 -1
  204. package/dist/web/assets/Compare-YfFYHwfK.js +0 -1
  205. package/dist/web/assets/Cost-ClaDz0YR.js +0 -1
  206. package/dist/web/assets/Data-jSFgAfej.js +0 -6
  207. package/dist/web/assets/Desktop-BofKeLVf.js +0 -1
  208. package/dist/web/assets/DesktopReview--WjeZh3w.js +0 -1
  209. package/dist/web/assets/Evidence-CJNzSQpY.js +0 -1
  210. package/dist/web/assets/Explore-BdFvqgF4.js +0 -2
  211. package/dist/web/assets/Features-CIBbw6PG.js +0 -1
  212. package/dist/web/assets/Flags-B62v4uWR.js +0 -2
  213. package/dist/web/assets/Flaky-Cut1kZw6.js +0 -1
  214. package/dist/web/assets/Impact-jOSl5Q0k.js +0 -3
  215. package/dist/web/assets/Jobs-DMJGgWtQ.js +0 -5
  216. package/dist/web/assets/KindPage-BbQWH5wa.js +0 -6
  217. package/dist/web/assets/Migration-BBgv7xXo.js +0 -2
  218. package/dist/web/assets/PageAgent-txbNoP6u.js +0 -1
  219. package/dist/web/assets/Product-BrXH81Ns.js +0 -7
  220. package/dist/web/assets/Production-CCVtFNGQ.js +0 -1
  221. package/dist/web/assets/Quality-Dxh-60A8.js +0 -1
  222. package/dist/web/assets/Readiness-DyJvSOLN.js +0 -1
  223. package/dist/web/assets/Record-Dnlkimjb.js +0 -1
  224. package/dist/web/assets/Regression-D2DDTwzs.js +0 -5
  225. package/dist/web/assets/Reports-ClcY7M0Q.js +0 -2
  226. package/dist/web/assets/Response-D9FYUvHg.js +0 -9
  227. package/dist/web/assets/RunDiff-CNImaEdz.js +0 -1
  228. package/dist/web/assets/Runs-CFvmdULI.js +0 -2
  229. package/dist/web/assets/Steps-BS66s0E1.js +0 -2
  230. package/dist/web/assets/TestCases-CrQEUtfD.js +0 -1
  231. package/dist/web/assets/TestData-e3IX0xwG.js +0 -2
  232. package/dist/web/assets/TestDebt-tXPoexMF.js +0 -1
  233. package/dist/web/assets/TestManagement-wjGaoZzI.js +0 -1
  234. package/dist/web/assets/Tosca-C5YaMLS0.js +0 -3
  235. package/dist/web/assets/WhatsNew-CwnRbDnd.js +0 -1
  236. package/dist/web/assets/azuredevops-BcQ5AFOM.js +0 -1
  237. package/dist/web/assets/crew-CWfjZIxE.js +0 -1
  238. package/dist/web/assets/families-DWilSDct.js +0 -1
  239. package/dist/web/assets/filters-CVzIOjPG.js +0 -1
  240. package/dist/web/assets/fold-tvLGnxD1.js +0 -1
  241. package/dist/web/assets/frame-Deu1IqzV.js +0 -13
  242. package/dist/web/assets/index-BWMIKyPB.js +0 -76
  243. package/dist/web/assets/index-C2Yq55oT.css +0 -2
  244. package/dist/web/assets/line-icons-C_amZ5-o.js +0 -1
  245. package/dist/web/assets/logos-C1NBtBMc.js +0 -1
  246. package/dist/web/assets/logos-DFyhMw0i.js +0 -1
  247. package/dist/web/assets/markdown-DC2HA0yZ.js +0 -10
  248. package/dist/web/assets/paletteCommands-Qxm5DZIs.js +0 -1
  249. package/dist/web/assets/parts-BR6dUwqn.js +0 -1
  250. package/dist/web/assets/productParts-BxdHuSBa.js +0 -1
  251. package/dist/web/assets/qualityParts-lz6eYVxC.js +0 -1
  252. package/dist/web/assets/recordTest-CcplpTS6.js +0 -1
  253. package/dist/web/assets/today-DuQFapJM.js +0 -1
  254. package/dist/web/assets/when-CHnpLdYw.js +0 -1
@@ -0,0 +1,122 @@
1
+ # Responsive tables
2
+
3
+ Large data tables often become unreadable on small screens as columns overflow or shrink beyond legibility. This guide demonstrates how to use **sticky positioning** to keep headers visible during scrolling and how to transform the table into a mobile-friendly "stacked" layout when space is limited.
4
+
5
+ ## Recommended Approach
6
+
7
+ The core of a responsive table is maintaining the relationship between data cells and their headers.
8
+
9
+ 1. **Semantic Foundation**: Use standard `<table>` elements with `<thead>`, `<tbody>`, and `<th>` elements.
10
+ 2. **Sticky Context**: Apply `position: sticky` to both column headers and row headers. This ensures that no matter how far a user scrolls in any direction, they never lose the context of what the data represents.
11
+ 3. **Adaptive Transformations**: Use `@container` queries instead of `@media` queries. This allows the table to adapt based on its own width (e.g., when placed in a sidebar or a narrow dashboard widget) rather than the entire viewport.
12
+ 4. **Label Injection**: In the stacked layout, the `<thead>` is hidden, and accessible headers are injected into each cell using `::before` pseudo-elements and CSS variables.
13
+ 5. **Legible Cells**: Keep long cell text on one line instead of letting columns shrink below legibility. See `single-line-overflow` for techniques for truncating it and revealing the full text on demand without UX friction.
14
+
15
+ ## Implementation Steps
16
+
17
+ ### 1. Markup and Layout
18
+
19
+ Structure your table with standard semantic headers. Use a `.table-wrapper` to handle overflow and provide a container for queries. Add a `tabindex="0"` attribute to the container, to ensure that people using only a keyboard can consistently scroll the table.
20
+
21
+ Give the wrapper a `role="region"` attribute to communicate its purpose. Provide it with an accessible name using `aria-labelledby` (referencing the `id` attribute of an existing element that captions/names the table) or an `aria-label` attribute.
22
+
23
+ ```html
24
+ <div tabindex="0" role="region" aria-labelledby="employee-table-caption" class="table-wrapper">
25
+ <table>
26
+ <caption id="employee-table-caption">Current employee directory</caption>
27
+ <thead>
28
+ <tr>
29
+ <th>Employee</th>
30
+ <th>Role</th>
31
+ <th>Status</th>
32
+ </tr>
33
+ </thead>
34
+ <tbody>
35
+ <tr>
36
+ <!-- Row header remains sticky horizontally on desktop,
37
+ and becomes a sticky card header on mobile -->
38
+ <th>Alex Rivera</th>
39
+ <td>Engineer</td>
40
+ <td>Active</td>
41
+ </tr>
42
+ </tbody>
43
+ </table>
44
+ </div>
45
+ ```
46
+
47
+ ### 2. Configure Sticky Headers
48
+ Enable scrolling and make headers sticky. Use logical properties and explicit z-index values to manage the stacking order.
49
+
50
+ ```css
51
+ .table-wrapper {
52
+ overflow: auto;
53
+ max-inline-size: 100%;
54
+ max-block-size: min(500px, 80vh);
55
+ container-type: inline-size;
56
+ }
57
+
58
+ table {
59
+ border-collapse: separate;
60
+ border-spacing: 0;
61
+ }
62
+
63
+ /* Sticky column headers (desktop) */
64
+ thead {
65
+ position: sticky;
66
+ inset-block-start: 0;
67
+ z-index: 1; /* Above sticky row headers */
68
+ }
69
+
70
+ /* Sticky row headers (desktop) */
71
+ tbody th {
72
+ position: sticky;
73
+ inset-inline-start: 0;
74
+ background: white; /* Required to cover background during scroll */
75
+ }
76
+ ```
77
+
78
+ ### 3. Responsive Stacked Layout
79
+ When space is limited, hide the original header row and transform the table into cards. Inject labels using pseudo-elements. Only provide alternative text for non-text content, otherwise this may result in both the text content and accessible name being announced by screen readers.
80
+
81
+ ```css
82
+ @container (width < 600px) {
83
+ table, thead, tbody, tr, th, td {
84
+ display: block;
85
+ }
86
+
87
+ thead {
88
+ /* MANDATORY: Hide column header from layout and screen readers. */
89
+ display: none
90
+ }
91
+
92
+ tr {
93
+ margin-block-end: 1.5rem;
94
+ border: 1px solid #ccc;
95
+ }
96
+
97
+ /* Sticky row headers at the top of each block/card */
98
+ tbody th {
99
+ position: sticky;
100
+ inset-block-start: 0;
101
+ z-index: 2;
102
+ background: #eee;
103
+ }
104
+
105
+ /* Define column labels as CSS variables (often set via JS) */
106
+ table {
107
+ --label-1: "Employee";
108
+ --label-2: "Role";
109
+ --label-3: "Status";
110
+ }
111
+
112
+ /* Inject labels */
113
+ td:nth-child(2)::before {
114
+ /* MANDATORY: If using non-text content, provide the accessible name (after the /) which ensures screen readers hear the text alternative. */
115
+ content: var(--label-2) ": ";
116
+ }
117
+ /* MANDATORY: Map the label for each column */
118
+ td:nth-child(3)::before {
119
+ content: var(--label-3) ": ";
120
+ }
121
+ }
122
+ ```
@@ -0,0 +1,178 @@
1
+ # Viewport-Aware Dropdowns
2
+
3
+ A revealed action panel or popover button group is a useful pattern for users to access additional functionality while taking up minimal space. This overlay pattern comes with layout complexity, as the panel must remain tethered to a trigger element while adapting to viewport constraints. Traditionally, this required complex JavaScript libraries (like Popper.js or Floating UI) to calculate positions and handle collisions.
4
+
5
+ CSS Anchor Positioning provides a declarative, performance-optimized way to handle these relationships entirely in CSS, allowing browsers to manage the positioning and overflow logic natively.
6
+
7
+ > [!NOTE]
8
+ > This guide demonstrates anchor-positioning and popover mechanics — it does not prescribe a specific accessible UI pattern. The trigger and panel below are shown as a plain **button-revealing-a-button-group**. If you need a true ARIA menu (`role="menu"` with arrow-key navigation), a combobox, a disclosure widget, or any other named pattern, layer that pattern's full semantics and keyboard contract on top of the positioning techniques shown here.
9
+
10
+ ### 1. Define the Button and Panel Relationship
11
+
12
+ The first step is to create a trigger button that opens the overlay container using the Popover API.
13
+
14
+ **MANDATORY Accessibility Distinction:** This pattern explicitly models a **button group revealed inside a popover** rather than a true ARIA menu. Do not apply `role="menu"` or `role="menuitem"` unless you fully implement the corresponding keyboard navigation contract (such as handling spatial arrow-key navigation between items). For the same reason, do not add `aria-haspopup` to the trigger — its value (`menu`, `listbox`, `tree`, `grid`, or the legacy `true`) is a promise that the target exposes a matching role, which this pattern does not.
15
+
16
+ ```html
17
+ <button popovertarget="action-panel">
18
+ Open Actions
19
+ </button>
20
+ <!-- Use the Popover API (`popover="auto"`) for the overlay to ensure it is placed in the top layer and handled accessibly by the browser. -->
21
+ <div id="action-panel" popover="auto" class="panel">
22
+ <button class="action-item" type="button">Edit</button>
23
+ </div>
24
+ ```
25
+
26
+ This creates an *implicit* anchor association between the button and the panel, so that the panel can be positioned relative to the button natively without needing `anchor-name` on the button or `position-anchor` on the panel.
27
+
28
+ ### 2. Positioning with `position-area`
29
+
30
+ Instead of manual `top`/`left` offsets, use `position-area` to place the target on a 3x3 grid relative to the anchor.
31
+
32
+ ```css
33
+ .panel {
34
+ /*
35
+ Position the panel below the anchor (block-end),
36
+ aligned to the start of the anchor and spanning to its end (span-inline-end).
37
+ */
38
+ position-area: block-end span-inline-end;
39
+
40
+ /* Reset insets to allow the grid to take control */
41
+ inset: auto;
42
+ }
43
+ ```
44
+
45
+ Prefer logical keywords (`span-inline-end`, `block-start`) over physical ones (`left`, `top`) to support RTL and different writing modes automatically.
46
+
47
+ **MANDATORY**: Do not mix physical and logical keywords in `position-area`.
48
+
49
+ ### 3. Implement Edge-Resilience (Fallbacks)
50
+
51
+ To prevent the panel from being cut off at the edge of the screen, define "try tactics" that the browser should attempt if the default position overflows.
52
+
53
+ ```css
54
+ .panel {
55
+ /*
56
+ If the panel overflows the bottom, flip it to the top (flip-block).
57
+ If it overflows the inline edges, flip it horizontally (flip-inline).
58
+ If it overflows both (e.g., in a corner), flip on both axes (flip-block flip-inline).
59
+ */
60
+ position-try-fallbacks: flip-block, flip-inline, flip-block flip-inline;
61
+ }
62
+ ```
63
+
64
+ If your dropdown or flyout includes a directional arrow or border that needs to change style depending on which fallback position was chosen, see `position-aware-tooltips` (references/ui-atoms/position-aware-tooltips.md). For declarative invocation of dialogs and popovers without JavaScript, see `declarative-dialog-popover-control`.
65
+
66
+ ## Fallback strategies
67
+
68
+ ### Fallbacks & browser support for Popover
69
+
70
+ Baseline status for Popover: Newly available. It's been Baseline since 2025-01-27.
71
+ Supported by: Chrome 116 (Aug 2023), Edge 116 (Aug 2023), Firefox 125 (Apr 2024), Safari 17 (Sep 2023), and Safari iOS 18.3 (Jan 2025).
72
+
73
+ The Popover API is mostly **progressive enhancement**, but its defining behaviors — top-layer promotion, light-dismiss, and `popovertarget` invocation — have no CSS-only equivalent. Older browsers need a polyfill, or a manual fallback if you would rather not ship one.
74
+
75
+ **Polyfill:** To support the `popover` attribute in older browsers, conditionally load [`@oddbird/popover-polyfill`](https://github.com/oddbird/popover-polyfill). **MANDATORY:** Feature detect by checking for the `popover` property on `HTMLElement.prototype`, and load the polyfill **only** when native support is missing — do NOT load it unconditionally.
76
+
77
+ With a bundler or import map:
78
+
79
+ ```js
80
+ // MANDATORY: Feature detect 'popover' on HTMLElement.prototype.
81
+ if (!Object.hasOwn(HTMLElement.prototype, "popover")) {
82
+ import("@oddbird/popover-polyfill");
83
+ }
84
+ ```
85
+
86
+ If not using a package manager, import from a CDN, e.g. `"https://unpkg.com/@oddbird/popover-polyfill@latest/dist/popover.min.js"`.
87
+
88
+ Caveats when using the polyfill:
89
+ - Do NOT use the `popover` IDL attribute for any code that may run before the polyfill is fully loaded. It will not be mirrored as an attribute, the popover will not be picked up by the polyfill, and the property will be shadowing the accessor the polyfill adds forever. Use `setAttribute()`/`removeAttribute()` instead.
90
+ - **Styling caveat:** The polyfill cannot define the real `:popover-open` pseudo-class, so it applies a `.\:popover-open` class instead. **MANDATORY:** Combine the two with `:is()` or `:where()`, otherwise browsers that lack `:popover-open` discard the entire rule:
91
+
92
+ ```css
93
+ [popover]:is(:popover-open, .\:popover-open) {
94
+ display: block;
95
+ }
96
+ ```
97
+
98
+ ### Fallbacks & browser support for Anchor positioning
99
+
100
+ Browser support for Anchor positioning: Limited availability.
101
+ Supported by: Chrome 157 (Nov 2026), Edge 157 (Nov 2026), and Safari 27 (Sep 2026).
102
+ Unsupported in: Firefox.
103
+
104
+ Without CSS Anchor Positioning, tethered elements such as `[popover]` overlays fall back to their default user-agent placement (centered in the viewport for popovers). Depending on whether spatial tethering is required for your use case, either conditionally load the polyfill or gate your positioning rules with `@supports`.
105
+
106
+ #### Option 1: Polyfill (`@oddbird/css-anchor-positioning`)
107
+
108
+ When the positioned element must stay spatially tethered to its trigger in unsupported browsers, conditionally load the `@oddbird/css-anchor-positioning` package.
109
+
110
+ **MANDATORY:** Feature-detect support via `CSS.supports("anchor-name: --a")` (or `"anchorName" in CSSStyleDeclaration.prototype`), and load the polyfill **only** when native support is missing — do NOT load it unconditionally.
111
+
112
+ With a bundler or import map:
113
+
114
+ ```js
115
+ // MANDATORY: Feature-detect anchor positioning support before loading the polyfill.
116
+ if (!CSS.supports("anchor-name: --a")) {
117
+ import("@oddbird/css-anchor-positioning");
118
+ }
119
+ ```
120
+
121
+ Without a bundler, import from a CDN inside a `<script type="module">`:
122
+
123
+ ```html
124
+ <!-- MANDATORY: Conditionally install the anchor positioning polyfill -->
125
+ <script type="module">
126
+ if (!CSS.supports("anchor-name: --a")) {
127
+ import("https://unpkg.com/@oddbird/css-anchor-positioning");
128
+ }
129
+ </script>
130
+ ```
131
+
132
+ **Polyfill caveats:**
133
+ - **No implicit anchors:** The polyfill does not support implicit anchor associations (such as those created by `popovertarget`, `commandfor`, `interestfor`, or `showPopover({ source })`). You **MUST** set a unique explicit `anchor-name` on each trigger and a matching `position-anchor` on the positioned element.
134
+ - **No `position-area` with `position-try-fallbacks`:** `position-area` with `position-try-fallbacks` is not supported by the polyfill. When using the polyfill on elements needing fallbacks, position elements using `anchor()` functions on inset properties (`top`, `left`, `right`, `bottom`) with `inset: auto` instead of `position-area`.
135
+ - **Do not wrap polyfilled rules in `@supports`:** Browsers without native anchor positioning evaluate `@supports (position-area: ...)` and `@supports (anchor-name: --a)` to `false` and discard the block before the polyfill can process it.
136
+
137
+ ```css
138
+ .trigger {
139
+ /* MANDATORY: Each trigger and positioned element pair must share a unique anchor name. */
140
+ anchor-name: --my-trigger;
141
+ }
142
+
143
+ [popover].anchored-overlay {
144
+ position-anchor: --my-trigger;
145
+ /* MANDATORY: Use anchor() on inset properties rather than position-area when using the polyfill on elements needing position-try-fallbacks. */
146
+ inset: auto;
147
+ top: anchor(bottom);
148
+ left: anchor(left);
149
+ margin: 0;
150
+ }
151
+ ```
152
+
153
+ #### Option 2: Progressive enhancement with `@supports` (no polyfill)
154
+
155
+ If you do not ship the polyfill, **DO NOT** set `inset: auto` or `margin: 0` unconditionally on a `[popover]` element that relies on `position-area` or `anchor()`. In browsers without anchor positioning, `inset: auto` overrides the user-agent centering (`inset: 0; margin: auto`) while `position-area` is ignored, leaving the popover stranded at `(0, 0)` or overlapping its trigger.
156
+
157
+ Instead, gate `inset: auto` and `margin: 0` inside `@supports` for the specific positioning feature used (for example, `@supports (position-area: block-end)` or `@supports (top: anchor(bottom))`) so unsupported browsers retain the default centered popover placement, or provide a matching `@supports not (...)` fallback layout (such as a fixed bottom sheet):
158
+
159
+ ```css
160
+ @supports (position-area: block-end) {
161
+ [popover].anchored-overlay {
162
+ inset: auto;
163
+ margin: 0;
164
+ position-area: block-end span-inline-end;
165
+ position-try-fallbacks: flip-block, flip-inline, flip-block flip-inline;
166
+ }
167
+ }
168
+
169
+ @supports not (position-area: block-end) {
170
+ /* Optional: override default popover centering with a fixed bottom bar */
171
+ [popover].anchored-overlay {
172
+ position: fixed;
173
+ inset: auto 0 0 0;
174
+ width: auto;
175
+ margin: 0;
176
+ }
177
+ }
178
+ ```
@@ -0,0 +1,108 @@
1
+ # Rearrange Items with Drag and Drop
2
+
3
+ Add reordering to an existing list or row, vertical or horizontal. Reorder the real children in the DOM (not via CSS `order` or `flex-direction: *-reverse`) so visual, keyboard, and reading order stay aligned. For free-form 2D repositioning of a floating element such as a dialog or toolbar, see `drag`. This guide covers one axis at a time; it does not cover reordering a grid or wrapped layout, or moving items between lists.
4
+
5
+ When items contain interactive controls or selectable text, provide a dedicated drag handle rather than making the entire item draggable. Then set up the pointer drag:
6
+
7
+ - Start pointer drags only for the primary button, and record the initial pointer offset.
8
+ - Apply `cursor: grab`/`grabbing`, `touch-action: none`, and `user-select: none` to the handle so item text remains selectable and page scrolling works outside the handle. Scope `touch-action: none` to the handle only: it disables touch scrolling over the element, which is acceptable on a small dedicated handle (the rest of the item and the page still scroll) but would trap scrolling if applied to the whole item or list.
9
+ - Because the pointer leaves the handle as soon as the drag moves, `:active` on the handle isn't enough to keep the grabbing cursor. Toggle a class on the root element for the length of the drag (removed in the drag-end cleanup) and set `cursor: grabbing` on it and its descendants.
10
+
11
+ ## Keep movement active while reordering
12
+
13
+ Keep the drag active and find the destination reliably:
14
+
15
+ - **Capture the pointer.** Keep the drag active after the pointer leaves the handle with `handle.setPointerCapture(event.pointerId)` on `pointerdown`, and clean up on `lostpointercapture` unless capture was deliberately re-established after a `before()` move (see the `moveBefore()` section).
16
+ - **Follow one pointer.** Remember the `pointerId` that started the drag and ignore `pointerdown`, `pointermove`, `pointerup`, and `pointercancel` from any other pointer, so an accidental second touch (such as the thumb holding a phone) can't start a competing drag or end the active one.
17
+ - **Let `Escape` cancel.** On `Escape`, record the item's current rect, clear its drag `translate` without moving it in the DOM, scroll the item's slot back into view if the container scrolled, animate it back from the recorded rect, and announce the cancellation.
18
+ - **Find the destination from layout, not `event.target`.** Pointer capture redirects `pointermove` `event.target` to the capturing handle. Clamp the pointer to the container's bounds on the list's axis and compare it with each sibling's layout midpoint. For a vertical list use `offsetTop + offsetHeight / 2`, with `position: relative` on the container and its `clientTop` and `scrollTop` accounted for. The drop spot is before the first sibling whose midpoint is below the pointer, or at the end if none is. For a horizontal row use `offsetLeft + offsetWidth / 2` with `clientLeft` and `scrollLeft`: `offsetLeft` and `scrollLeft` share one coordinate space in both reading directions (`scrollLeft` is negative once a right-to-left row is scrolled), so the same sum works for either. In a right-to-left row the DOM order runs right to left, so insert before the first sibling whose midpoint the pointer is already past, rather than the first one it has not reached.
19
+ - **Why layout midpoints.** Layout positions ignore in-flight `translate` animations and padding gaps, so a pointer past either edge reliably resolves to the first or last place. `document.elementFromPoint()` hit-tests painted positions and can miss items while siblings are animating. Use `document.elementFromPoint(event.clientX, event.clientY)` only when the destination is one of several containers (such as board columns).
20
+
21
+ When an item gets dragged, communicate where it will be dropped. This can be done by reserving space, showing an explicit drop marker, or showing a clone at the target position. When using a drop marker, consider collapsing the source slot so the marker alone signals the destination. Avoid combining a marker with a leftover gap that suggests a second drop target.
22
+
23
+ Don't reorder while the pointer moves: shifting siblings feel jittery. Keep the source item in its slot and show a drop marker. This is the default for a single-axis list:
24
+
25
+ - **Render a marker, not a shift.** Set `data-drop` on the list during a drag and draw the marker with its `::before` (ring) and `::after` (line), both `position: fixed; pointer-events: none`. Don't append an element to `<body>`.
26
+ - **Place it in the gap.** On every drop-spot update and scroll step, set `--drop-x`, `--drop-y`, `--drop-w` and `--drop-h` from the neighbors' `getBoundingClientRect()`, centering the line in the gap between the previous and next item (on the inline axis, flipped in right-to-left, for rows). Don't use CSS anchor positioning (it drifts while autoscrolling), and keep `transform`, `filter` and `contain` off the list and its ancestors.
27
+ - **Skip no-op drops.** Show no marker when the drop spot is the item's own slot. Remove `data-drop` and the custom properties when the drag ends.
28
+ - **Make it themeable.** Drive color, line size, ring size, gap, lifted-item opacity and shadow from custom properties (such as `--drop-marker-color`) with defaults that suit the host design system, and use `Highlight` under `forced-colors: active`.
29
+ - **Move once on release.** On `pointerup`, if the drop spot differs from the item's current next sibling, move the existing item node atomically with `container.moveBefore(item, referenceNode)` rather than recreating it, so internal state (such as focused controls, input values, scroll position, media, or custom element instances) and active pointer capture are preserved. Keyboard moves use the same call on each step. Then animate the move:
30
+
31
+ - **Animate every move.** Items should visibly travel instead of jumping, including the move on release and keyboard moves. Record each sibling's `getBoundingClientRect()` before the move, then afterwards animate the `translate` property from the old offset (on both axes, correcting for any scroll that happened) to `0 0` (FLIP).
32
+ - **Animate the release.** When the pointer is released, animate the item from its released position to its final rect (FLIP), measured after finishing the item's in-flight animations (`item.getAnimations().forEach((animation) => animation.finish())`) because otherwise the rect includes the animation's offset. Keep it raised until the animation finishes.
33
+ - **Respect reduced motion.** Skip the animations under `prefers-reduced-motion: reduce`.
34
+ - **Lift the real item; don't clone it.** Keep the dragged item in the DOM and in its layout slot, and follow the pointer with a `translate` (add the list's scroll change since the grab so auto-scroll keeps it under the pointer). Give it `position: relative`, a raised `z-index`, a slight `scale`, a shadow, and `pointer-events: none`. Its empty slot shows where it was picked up from. A clone duplicates IDs, loses state, breaks descendant selectors, framework bindings, and `idref`s, and ends up as invalid markup when appended outside the list. On release, animate the item from its dragged position to its new spot.
35
+ - **Handle a quick re-grab.** Don't clear the item's drag state from a finished animation's callback if a new drag of that item has already started.
36
+
37
+ ## Scroll while dragging
38
+
39
+ If the items live in a scrollable container, scroll it while the pointer is near or beyond its start or end edge on the list's axis (top and bottom, or left and right for a row, using `scrollTop` or `scrollLeft`), so off-screen items stay reachable (especially on small viewports). Run a `requestAnimationFrame` loop for the duration of the drag that scales scroll speed with how far the pointer is into an edge zone (the dragged item's size on the list axis, capped at a third of the container's size so the two zones never overlap), continuing to increase beyond the edge up to a cap, and uses frame time rather than a fixed step. After each scroll change, re-run drop-spot detection with the last pointer position, clamped into the container's bounds, because the pointer hasn't moved. Avoid `scroll-behavior: smooth` on that container. Give it space on every side so focus rings and elevation shadows aren't clipped: the space must cover the focus ring's outline width and offset plus the grabbed item's scale growth (about 1rem for a 3px outline, 2px offset, and `scale(1.02)`), and `overflow-y: auto` also clips on the x axis. Put the end space (bottom, or inline-end for a row) on the last item's margin rather than the container's padding, because some engines omit a grid or flex container's end padding from its scrollable overflow. Cancel the loop when the drag ends.
40
+
41
+ ## Support keyboard reordering
42
+
43
+ Provide a keyboard-accessible alternative to pointer reordering. Choose an interaction that fits how frequently users reorder items and how easily they need to discover it:
44
+
45
+ - **Visible movement controls or an actions menu**: Best default for discoverability and screen-reader compatibility, because activating standard buttons works in screen-reader browse modes without intercepting arrow keys. Use an actions menu when persistent inline buttons add too much visual clutter.
46
+ - **Direct arrow keys (or modifier + arrow keys, such as `Alt` + arrow keys) on a focusable handle or item**: Suits frequent reordering with minimal UI chrome. Give the handle an accessible name that identifies both the item and the reorder action, and note that screen-reader browse modes may intercept bare arrow keys on a `<button>` handle unless paired with explicit movement controls or modifier keys.
47
+ - **Grab–move–drop mode (`Space` or `Enter` to pick up, arrow keys to move along the list's axis, `Space` or `Enter` to drop, `Escape` to cancel)**: Arrow keys do nothing until the item is grabbed, which keeps them from conflicting with screen-reader navigation. Toggle `aria-pressed` on the handle, announce the grabbed state and available keys on pickup, restore the item to its original DOM position on `Escape`, and drop when the handle itself loses focus (not only when focus leaves the whole list, since the next stop is often another control in the same item), ignoring any blur caused by the move itself.
48
+
49
+ The keys follow the list's axis: `ArrowUp` and `ArrowDown` for a vertical list, `ArrowLeft` and `ArrowRight` for a row. Arrow keys follow the visual direction, so in a right-to-left row `ArrowLeft` moves the item later in the DOM and `ArrowRight` earlier. Ignore the other axis's keys, use matching direction labels and icons on any move buttons, and name the direction in the announcement.
50
+
51
+ For any approach, announce the item and its new position in a polite live region, resetting its text and delaying the update briefly (see the `moveBefore()` fallback below) so moves that refocus the handle are still announced. Announce only when the position actually changed (not for a click or a drop in place), while still announcing a cancellation. Show focus and the grabbed state on the item being moved, not just the handle:
52
+
53
+ - **Keep the item in view.** After each keyboard move (including `Escape` restoring the original position) and each pointer drop, call `item.scrollIntoView({ block: 'nearest', inline: 'nearest' })` after the move but before starting the animation, because an in-flight `translate` skews the position it scrolls to. Restore focus afterwards with `focus({ preventScroll: true })` so the browser doesn't scroll again, and give items a `scroll-margin` matching the space around them in the container.
54
+ - **Reveal the whole item on keyboard focus.** The browser otherwise scrolls only the focused handle into view and leaves the rest of the item and its focus ring clipped. When keyboard focus enters an item (for example with `Tab`), scroll the item the same way (`block` and `inline` both `'nearest'`) from a `focusin` handler that checks `:focus-visible` and skips items with running animations.
55
+ - **Draw the focus ring on the item** with `.item:has(.handle:focus-visible)`. For grab–move–drop handles, show a visible key hint on the focused item (an `aria-hidden="true"` element in the item reading "Space to reorder", switching to "Arrows to move · Space to drop · Esc to cancel" while grabbed—keep instructional text in the DOM rather than CSS `content` so it stays translatable), and fade the handle slightly at rest so reordering reads as available. Also apply the handle's hover style on `:focus-visible` (`.handle:is(:hover, :focus-visible)`) so sighted keyboard users see the handle is activatable; use a fill rather than an outline so it doesn't read as a second focus ring, and give the grabbed (`aria-pressed`) state its own pressed look.
56
+ - **Elevate the grabbed item** with full opacity, a slight `scale()`, and `box-shadow`. Avoid rotation, especially when movement is on one axis.
57
+ - **Keep the layout shrinkable.** Make each row's flexible column shrinkable (`minmax(0, 1fr)` with form controls at `width: 100%`) so the movement controls stay visible on narrow viewports without horizontal scrolling.
58
+
59
+ ### Align reading order with visual layout
60
+
61
+ Keep the DOM and keyboard focus order understandable in relation to the visual layout. If reordering is provided through separate controls, ensure the item's context is available before or alongside those controls. If the drag handle is focusable, give it an accessible name that identifies the item and its reordering function. Position controls to suit the layout and writing direction without making the resulting reading or focus order confusing.
62
+
63
+ For complex layouts where visual and DOM order cannot naturally align, use the **`reading-flow`** CSS property inside grid/flex containers to instruct the browser's tab order to follow visual coordinates rather than DOM source order:
64
+ ```css
65
+ .task {
66
+ display: grid;
67
+ grid-template-columns: auto minmax(0, 1fr) auto; /* minmax(0, ...) lets the middle column shrink at narrow widths */
68
+ reading-flow: grid-rows; /* Follows visual layout and tab order by row */
69
+ }
70
+ ```
71
+
72
+ ### Disable boundaries and safeguard focus
73
+ Keep moves within valid destinations. If items can move between containers, make those destinations available to keyboard users too. At the boundary of a container, prevent further movement only when there is no valid destination in that direction.
74
+
75
+ After moving an item, keep focus on its handle. If the implementation uses separate movement buttons instead, keep focus on the activated button or shift it to the alternative movement control on the same item when the activated control becomes disabled.
76
+
77
+ ## Decide on fallback behavior
78
+
79
+ When reordering is supplementary, keep the collection readable and usable in its default DOM order without JavaScript. If the order represents user-controlled data or directly affects behavior—for example, task priority, playlist order, or workflow sequence—treat reordering as essential and provide the required pointer and keyboard interactions rather than presenting the static order as equivalent behavior.
80
+
81
+ ## Browser support and fallback strategies
82
+
83
+ ### `moveBefore()`
84
+
85
+ Browser support for moveBefore(): Limited availability.
86
+ Supported by: Chrome 133 (Feb 2025), Edge 133 (Feb 2025), and Firefox 144 (Oct 2025).
87
+ Unsupported in: Safari.
88
+
89
+ If your Baseline target does not support `moveBefore()`, feature-detect with `'moveBefore' in Element.prototype` and fall back to `referenceNode.before(item)` (or `container.append(item)` when there is no reference node) with the existing item node. Because `before()` removes and reinserts the node, it has two side effects to handle:
90
+
91
+ - **It drops active pointer capture.** Keep the `pointermove`, `pointerup`, and `pointercancel` listeners on `document`, where captured events still bubble. After the move, re-call `handle.setPointerCapture(event.pointerId)` when `hasPointerCapture()` is false, and end the drag on `lostpointercapture` only if capture is not re-established.
92
+ - **It blurs focused descendants.** Explicitly call `.focus()` on the active handle or movement button after moving. Also delay the live-region update by about 500 ms (debounced, clearing the previous message first), because the focus re-announcement otherwise swallows the position announcement in screen readers such as VoiceOver in Safari.
93
+
94
+ ### `reading-flow`
95
+
96
+ Browser support for reading-flow: Limited availability.
97
+ Supported by: Chrome 137 (May 2025) and Edge 137 (May 2025).
98
+ Unsupported in: Firefox and Safari.
99
+
100
+ In browsers that do not support `reading-flow`, sequential focus navigation follows DOM source order. Structure each item's DOM order so interactive controls appear in a logical reading and tab sequence without relying on CSS visual reordering.
101
+
102
+ ### `user-select`
103
+
104
+ Browser support for user-select: Limited availability.
105
+ Supported by: Chrome 54 (Oct 2016), Edge 79 (Jan 2020), and Firefox 69 (Sep 2019).
106
+ Unsupported in: Safari.
107
+
108
+ Include `-webkit-user-select: none` before `user-select: none` on the drag handle so text selection stays suppressed during dragging in Safari.
@@ -0,0 +1,89 @@
1
+ # Light-Dismiss a Dialog
2
+
3
+ Modern modal dialogs often support "light-dismiss," allowing users to close a dialog by clicking or tapping the backdrop (the area outside the dialog). The `closedby` attribute provides a declarative way to enable this behavior without custom JavaScript.
4
+
5
+ ## Implementation
6
+
7
+ To enable light-dismiss:
8
+
9
+ 1. Add `closedby="any"` to the `<dialog>` element.
10
+ 2. Open the dialog using `dialog.showModal()`.
11
+
12
+ ### Attribute Values
13
+
14
+ - `any`: Enables light-dismiss (clicking the backdrop), "close requests" (the `Esc` key), and developer mechanisms (e.g., `dialog.close()`).
15
+ - `closerequest`: Enables "close requests" and developer mechanisms only. This is the default for modal dialogs.
16
+ - `none`: Only developer mechanisms can close the dialog.
17
+
18
+ ### Styling the Backdrop
19
+ When a dialog is opened as a modal using `showModal()`, the browser generates a `::backdrop` pseudo-element. This backdrop covers the entire viewport and sits directly behind the dialog.
20
+
21
+ ```css
22
+ /* Style the backdrop to indicate the dialog is modal */
23
+ dialog::backdrop {
24
+ background-color: rgba(0, 0, 0, 0.5);
25
+ backdrop-filter: blur(2px); /* Optional: add blur for modern browsers */
26
+ }
27
+ ```
28
+
29
+ ## Example
30
+
31
+ ```html
32
+ <!-- MANDATORY: Use closedby="any" to enable light-dismiss behavior -->
33
+ <dialog id="myDialog" closedby="any" aria-labelledby="dialogTitle">
34
+ <form method="dialog">
35
+ <h2 id="dialogTitle">Feedback</h2>
36
+ <p>Click outside this box or press Esc to dismiss.</p>
37
+ <button type="submit">Close</button>
38
+ </form>
39
+ </dialog>
40
+
41
+ <button onclick="document.getElementById('myDialog').showModal()">Open Dialog</button>
42
+ ```
43
+
44
+ ## Constraints & Accessibility
45
+
46
+ - **MANDATORY**: Use `closedby="any"` to enable light-dismiss declaratively.
47
+ - **MANDATORY**: Always open modal dialogs with `showModal()`. This ensures the dialog is in the top layer, focus is trapped, and the `Esc` key is handled.
48
+ - **DO**: Ensure that there is always a close button visible to provide people with a clear, alternative way to close the modal dialog.
49
+ - **DO**: Use `aria-labelledby` or `aria-label` to provide an accessible name for the dialog.
50
+ - **DO NOT**: Use `closedby` for non-modal dialogs (opened with `show()`), as they do not have a backdrop and won't trigger light-dismiss.
51
+ - **DO NOT**: Use the `click` event for critical logic that should happen *before* closing; instead, listen for the `close` or `cancel` events.
52
+
53
+ Ensure that there aren't components in the modal dialog that themselves use the `Esc` key for interaction, as this may lead to the dialog being inadvertently closed. If the modal dialog does include components that use the `Esc` key (e.g. a menu or a combobox), ensure that when these components are focused, they capture the `Esc` key press and use it accordingly, and that the dialog is not closed accidentally.
54
+
55
+ ## Fallback strategies
56
+
57
+ Browser support for <dialog closedby>: Limited availability.
58
+ Supported by: Chrome 134 (Mar 2025), Edge 134 (Mar 2025), and Firefox 141 (Jul 2025).
59
+ Unsupported in: Safari.
60
+
61
+ **MANDATORY**: For browsers that do not yet support `closedby`, you **must** implement a fallback for light-dismiss by checking if a click occurred outside the dialog content's boundaries using the following script:
62
+
63
+ ```javascript
64
+ const dialog = document.querySelector('dialog');
65
+
66
+ // Fallback for browsers without closedby support
67
+ if (!('closedBy' in HTMLDialogElement.prototype)) {
68
+ dialog.addEventListener('click', (event) => {
69
+ // 1. When clicking the backdrop, the event target is the dialog element itself.
70
+ // Ignore clicks where the target is a child element inside the dialog.
71
+ if (event.target !== dialog) return;
72
+
73
+ // 2. Check if the click coordinates fall within the dialog's content box.
74
+ // This distinguishes between a click on the backdrop vs a click on the dialog's background/padding.
75
+ const rect = dialog.getBoundingClientRect();
76
+ const isDialogContent = (
77
+ rect.top <= event.clientY &&
78
+ event.clientY <= rect.top + rect.height &&
79
+ rect.left <= event.clientX &&
80
+ event.clientX <= rect.left + rect.width
81
+ );
82
+
83
+ if (isDialogContent) return;
84
+
85
+ // 3. Since the click was outside the content area (on the backdrop), manually close the dialog.
86
+ dialog.close();
87
+ });
88
+ }
89
+ ```
@@ -0,0 +1,97 @@
1
+ # Motion
2
+
3
+ - Use `clip-path` and `mask-image` for custom geometric reveals and smooth fade-outs. Both also clip the element's own focus outline, so when the clipped or masked element is focusable (for example, a scroll container with `tabindex="0"`), draw its focus indicator on a parent element that isn't clipped or masked.
4
+ - Use **Scroll-Driven Animations** (`animation-timeline: scroll()`) for non-essential scroll-bound effects instead of JS listeners.
5
+ - Use **View Transitions** to animate between complex layout states seamlessly.
6
+
7
+ ## Performance
8
+
9
+ - Prefer to animate `opacity` and `transform` (including individual transform properties, e.g. `translate` instead of `left/right/top/bottom`) to ensure animations stay on the compositor thread.
10
+ - Use `transition-behavior: allow-discrete`, `@starting-style`, and (for top-layer elements like `<dialog>` or `[popover]`) `overlay` to animate discrete entry and exit states natively; see `animate-element-entry-exit` and `animate-to-from-top-layer`.
11
+
12
+ ```css
13
+ .popover-reveal {
14
+ /* Transition discrete display and top-layer overlay alongside opacity */
15
+ transition:
16
+ opacity ease-out,
17
+ display,
18
+ overlay;
19
+ transition-duration: 0.2s;
20
+ /* Separate after transition so the shorthand doesn't reset it or fail in older browsers */
21
+ transition-behavior: allow-discrete;
22
+ }
23
+ ```
24
+
25
+ ## Accessibility
26
+
27
+ - **Provide a pause mechanism**: Allow users to stop auto-running carousels, banners, or other persistent animations. Any moving, blinking, or scrolling content that starts automatically, lasts more than five seconds, and is shown alongside other content needs a visible control to pause, stop, or hide it, such as a `<button>` next to the content that works with the keyboard (WCAG 2.2.2 Pause, Stop, Hide). `prefers-reduced-motion` doesn't replace the control, because users who haven't turned on that setting still need to stop the motion. If the button's label changes between "Pause" and "Play", don't also set `aria-pressed`, or screen readers announce a pressed "Play" button.
28
+ - **Default to static views**: Consider defaulting to static states and allowing users to opt in to motion.
29
+ - **Don't exceed flash limits (three per second)**: Never include rapid light-to-dark flashing. Such effects can cause seizures. This applies whatever the user's motion preference, so don't put flashing content inside `@media (prefers-reduced-motion: no-preference)` either (WCAG 2.3.1 Three Flashes or Below Threshold: nothing flashes more than three times in any one-second period).
30
+ - **Keep the final state**: When you turn off an animation, make sure the element still ends in its final state, so content isn't left hidden (for example, at `opacity: 0`) and focus and selection indicators still appear.
31
+
32
+ ### Respect reduced motion
33
+
34
+ Always respect reduced motion preferences. Choose between `@media (prefers-reduced-motion: no-preference)` and `@media (prefers-reduced-motion: reduce)` based on whether reduced motion removes the animation entirely or only adjusts its parameters:
35
+ - Use `@media (prefers-reduced-motion: no-preference)` when the reduced-motion strategy is to **not have the animation at all** (apply the animation only where needed rather than declaring it broadly and canceling it with `animation: none`).
36
+ - Use `@media (prefers-reduced-motion: reduce)` when the reduced-motion strategy is to **change animation parameters** (such as slowing down `animation-duration`).
37
+
38
+ **DO NOT** globally apply `animation-duration: 0.01ms;` as it can cause certain animations to become _more_ jarring. Instead, handle reduced motion on a case-by-case basis by nesting the `@media` query inside the rule so both versions are kept together. Keep non-motion transitions (such as `color` or `background-color` changes on links and buttons) enabled; only dampen or disable spatial movement, scaling, rotation, or persistent animations.
39
+
40
+ #### Opt in to motion with `@media (prefers-reduced-motion: no-preference)`
41
+
42
+ When reduced motion should have no animation at all, default to the static state and enable the animation inside `@media (prefers-reduced-motion: no-preference)` instead of setting `animation` and overriding it with `animation: none`:
43
+
44
+ ```css
45
+ /* Good: Default to static state and opt in to full motion */
46
+ .spinner {
47
+ @media (prefers-reduced-motion: no-preference) {
48
+ animation: spin 1s linear infinite;
49
+ }
50
+ }
51
+ ```
52
+
53
+ #### Adjust animation parameters with `@media (prefers-reduced-motion: reduce)`
54
+
55
+ When the animation should still run under reduced motion with gentler parameters, declare the base animation and override only the changed properties inside `@media (prefers-reduced-motion: reduce)`:
56
+
57
+ ```css
58
+ /* Good: Slow down the animation for reduced motion instead of canceling it */
59
+ progress:not([value]) {
60
+ animation: slide 1s infinite linear;
61
+ @media (prefers-reduced-motion: reduce) {
62
+ animation-duration: 20s;
63
+ }
64
+ }
65
+ ```
66
+
67
+ ## Working with animation and transition events in JavaScript
68
+
69
+ On both the `AnimationEvent` (`animationstart`, `animationiteration`, `animationend`, `animationcancel`) and `TransitionEvent` (`transitionrun`, `transitionstart`, `transitionend`, `transitioncancel`) interfaces, `event.target` gives you the originating DOM element. To access the specific `Animation` object (`Animation`, `CSSAnimation`, or `CSSTransition`) that triggered the event, use the readonly `event.animation` property.
70
+
71
+ When `event.animation` is not available, you can usually find the `Animation` instance by calling `event.target.getAnimations()` and filtering by `event.animationName` (or `event.propertyName` for transitions). However, using `event.animation` directly is preferred, in order to avoid several scenarios where this fallback that filters `event.target.getAnimations()` does not work as expected:
72
+
73
+ - Web Animations API (`element.animate()`) animations do not have an `animationName`, so they cannot be matched by name when filtering `event.target.getAnimations()`.
74
+ - Filtering by `animationName` for `AnimationEvent`s is ambiguous when multiple animations with the same name are attached to the same element.
75
+ - Note that filtering on `transitionProperty` for `TransitionEvent`s works as there is only one event per transition property.
76
+ - `event.target` always points to the originating DOM element, so it does not distinguish between animations running on the element itself versus one of its pseudo-elements — whereas `event.animation.effect.pseudoElement` exposes the target pseudo-element directly.
77
+
78
+ ```js
79
+ // Works in most basic CSS animation cases, but fails for WAAPI animations,
80
+ // duplicate animation names on the same element, or pseudo-elements.
81
+ document.addEventListener('animationstart', (event) => {
82
+ const animation = event.target
83
+ .getAnimations()
84
+ .find((anim) => anim.animationName === event.animationName);
85
+ console.log(animation);
86
+ });
87
+
88
+ // PREFERRED: Directly access the exact Animation object via event.animation
89
+ document.addEventListener('animationstart', (event) => {
90
+ const animation = event.animation;
91
+ console.log(animation);
92
+ });
93
+ ```
94
+
95
+ You can feature-detect support using `'animation' in AnimationEvent.prototype` (or `'animation' in TransitionEvent.prototype`).
96
+
97
+ When reduced motion means an animation or transition never runs (it's only applied inside `@media (prefers-reduced-motion: no-preference)`, set to `none`, or given a zero duration and no delay), `animationend` and `transitionend` never fire. If your code waits for these events to remove or hide an element, continue immediately when `element.getAnimations()` returns an empty array, or keep a short opacity transition instead of removing it.