diff --git a/clint/updates/20260727-add-option-to-close-dropdown-on-scroll/CHANGELOG.md b/clint/updates/20260727-add-option-to-close-dropdown-on-scroll/CHANGELOG.md new file mode 100644 index 00000000..95c7d2c1 --- /dev/null +++ b/clint/updates/20260727-add-option-to-close-dropdown-on-scroll/CHANGELOG.md @@ -0,0 +1,48 @@ +# Add option to close dropdown on scroll + +**Release date:** 2026-07-27 + +## Summary + +Adds an opt-in `data-dropdown-close-on-scroll` attribute to the dropdown component. When present, the +menu closes on the first scroll event instead of staying open and repositioning itself. The default +behaviour is unchanged: without the attribute the menu keeps following its trigger on scroll. + +## Highlights + +- ✅ **Close on Scroll** - Add `data-dropdown-close-on-scroll` to dismiss the menu as soon as the user scrolls +- ✅ **Opt-in** - Purely additive; dropdowns without the attribute behave exactly as before +- ✅ **Useful for anchored menus** - Handy when the trigger scrolls out of view and a repositioned menu would feel disconnected + +## Added + +- `data-dropdown-close-on-scroll` attribute on `[data-dropdown]`, read once during initialisation + (`frontend/js/components-core/dropdown.component.ts`) + +## Changed + +- The dropdown's scroll handler now closes the menu when the attribute is set, after repositioning + +## Usage + +```html + +
+``` + +# Manual intervention + +> ⚠️ **ATTENTION**: +> This update force-syncs `frontend/js/components-core/dropdown.component.ts`, which is normally +> excluded from the frontend sync. If your project has local changes to that file, re-apply them +> after updating. +> +> Run `yarn build` (or `yarn dev`) afterwards so the recompiled component ends up in your bundle. + +## Docs + +You can find the [documentation on our docs](https://statikbe.github.io/craft/frontend/components/dropdown.html). diff --git a/clint/updates/20260727-add-option-to-close-dropdown-on-scroll/update.json b/clint/updates/20260727-add-option-to-close-dropdown-on-scroll/update.json new file mode 100644 index 00000000..c482f87c --- /dev/null +++ b/clint/updates/20260727-add-option-to-close-dropdown-on-scroll/update.json @@ -0,0 +1,12 @@ +{ + "id": "20260727-add-option-to-close-dropdown-on-scroll", + "title": "Add option to close dropdown on scroll", + "description": "Adds an opt-in data-dropdown-close-on-scroll attribute that closes the dropdown menu as soon as the user scrolls, instead of repositioning it.", + "date": "2026-07-27", + "issues": [572], + "pr": 660, + "requires": [], + "frontend": { + "modify": ["js/components-core/dropdown.component.ts"] + } +} diff --git a/clint/updates/index.json b/clint/updates/index.json index e70e7e60..e49f7343 100644 --- a/clint/updates/index.json +++ b/clint/updates/index.json @@ -90,6 +90,19 @@ "legacyVersion": "1.0.9", "hasOps": false }, + { + "id": "20260727-add-option-to-close-dropdown-on-scroll", + "seq": 9, + "title": "Add option to close dropdown on scroll", + "date": "2026-07-27", + "issues": [ + 572 + ], + "pr": 660, + "requires": [], + "legacyVersion": null, + "hasOps": true + }, { "id": "20260727-remove-aria-expanded-on-video-toggle", "seq": 9, diff --git a/docs/src/examples/dropdown.md b/docs/src/examples/dropdown.md index 4406685d..d11a02af 100644 --- a/docs/src/examples/dropdown.md +++ b/docs/src/examples/dropdown.md @@ -24,9 +24,22 @@ Item 3 +Anim laborum in sit sint ea consectetur pariatur ullamco id veniam voluptate mollit enim. Exercitation tempor amet aliqua esse laboris irure incididunt velit elit amet labore mollit nulla. Commodo exercitation non sint consectetur pariatur consequat enim ad commodo. Est consequat dolore exercitation adipisicing voluptate consectetur laboris.
+ +Ullamco duis cupidatat est aute velit. Eiusmod labore veniam nulla id voluptate. Et laboris officia quis ea. Aliquip reprehenderit reprehenderit quis. Ut eu in irure fugiat laboris reprehenderit cupidatat amet qui incididunt eu. Deserunt labore sit incididunt. Consectetur aliqua cillum aliquip irure irure aliquip enim mollit eu enim ut exercitation anim et duis. Magna ea Lorem quis eu ut laborum minim et.
- -