Releases: zipper/collapsable.js
Release list
4.2.0
What's Changed
-
✨ Restore original attributes on
destroy()(#39).
On destroy, collapsable now restoresrole,hidden,aria-hidden,aria-controlsandaria-expanded/aria-selectedto their original state instead of unconditionally removing them. A new sharedAttributeSnapshotutility (remember/restore/clear) is exported from the ESM build alongsidedeepMerge. -
🐞 Keep author-defined attributes intact (#39).
destroy()no longer stripsrole/aria-controls/aria-expandedthat were present before initialization and not added by collapsable. Ahidden/aria-hiddenattribute present on a box before init is now restored as well, fixing box visibility after destroy.Generated
ids and the rewrittenhref(#→#id) are intentionally left in place.
Full Changelog: 4.1.4...4.2.0
4.1.4
What's Changed
- 🐞 Animation detection deferred to the next animation frame
Theexpanded.collapsable/collapsed.collapsableevents could be dispatched prematurely, becausegetAnimations()was called synchronously right after the class change, before the browser had registered the CSS transitions it triggered. Animation detection now runs insiderequestAnimationFrame, so these finished events fire only once the animations have actually started (or immediately when there are none). - 🐞 Media changes no longer affect unrelated collapsable items
handleDefaultExpandedis now called with the relevantMediaQueryListwhen a media condition changes, so only items matching that media query are reset. This completes the fix introduced in 4.1.3, where themediaparameter was added but never passed at the call site, leaving the filter inactive. - 🔧 Modernized release workflow
npm publishing now uses provenance via OIDC Trusted Publishing (GPG signing of dist files has been removed), the GitHub release draft is created withgh release create, and the CI/publish actions were bumped to v5.
Full Changelog: 4.1.3...4.1.4
4.1.3
What's Changed
- 🐞 Media changes no longer affect unrelated collapsable items (#38)
When the media condition changes for a group of collapsable items, thehandleDefaultExpandedmethod now only processes items whose media matches the current condition. - 🐞 Filter expanded items by media query in
getExpanded(#38)
ThegetExpandedmethod now checks media query conditions, ensuring only items matching their media settings are considered expanded. Items without a matching media condition (collapsable is inactive) are ignored. This handles edge cases where items in the same group have mixed media conditions. - 🐞 Improved accordion behavior (#38)
During accordion initialization, all items except the default expanded one are closed first, and only then is the default expanded item opened. Additionally, when collapsing other items upon expanding one, the logic avoids collapsing the item that will be re-expanded immediately afterward.
Full Changelog: 4.1.2...4.1.3
4.1.2
What's Changed
- 🐞 Check for responsive collapsable in
handleExpandCollapse(#37)
ThehandleExpandCollapsemethod checks whether the collapsable element is responsive. If it is, the method proceeds only if the media query matches. - 🐞 Better handling of
dataset.collapsableState(#37)
Thedataset.collapsableStateis modified only whenCollapsableEvents are associated with the expanding or collapsing elements. This ensures that events from nested collapsable elements do not affect thedataset.collapsableStatefurther up the DOM tree. - 🐞 Better attribute clean up on destroy (#37)
On destroy, thedataset.collapsableStateis removed from boxes, and theroleattribute is removed fromextLink. - 🛠️ npm audit fix
Full Changelog: 4.1.1...4.1.2
4.1.1
Full Changelog: 4.1.0...4.1.1
- 🐞 Removing forgotten
console.log.
4.1.0
What's Changed
✨ Features
-
✨Attribute
data-collapsable-stateis being set (#35).
While aCollapsableItemis expanding or collapsing, thedata-collapsable-stateattribute is set toexpandingorcollapsing. This attribute is removed immediately after the transition completes.This can be useful in CSS, for example, to apply
@starting-styleonly to the item currently expanding or collapsing. This makes it easier to usedisplay: nonefor hiding collapsed items while still allowing transitions for expansion. Additionally, when applied via the data attribute,@starting-stylewon’t affect nested collapsable elements that are already expanded, preventing unwanted transitions. -
✨Automatically detect delay for
[expanded|collapsed].collapsableevents (#36)
Previously, the delay for the[expanded|collapsed].collapsableevents was defined by thefxDurationoption. From this version, the delay is automatically detected using the Web Animations API from the box elements. Optionally, you can also detect animations within the subtree of box elements using theeventDelayGetAnimationsWithSubtreeoption.The
fxDurationoption has been renamed toeventDelayTimeout. Since the box may contain elements with infinite animations (or the box itself may have such animations), a hard timeout may be required to ensure that the[expanded|collapsed].collapsableevents are dispatched eventually. This timeout can now be set using the renamedeventDelayTimeoutoption. Default value isundefined, meaning that no timeout is set. -
🐞 Type of
(nowfxDurationeventDelayTimeout) has been fixed.
Previously incorrectly typed asfxDuration: 0, now typed aseventDelayTimeout: number | undefined.
⚠️ BC Break
- The option
fxDurationhas been renamed toeventDelayTimeoutand has a slightly different meaning. Just renaming the option would work, but the[expanded|collapsed].collapsableevents may be dispatched earlier if there are no animations on the box elements. Also the option may be not needed at all anymore.
Full Changelog: 4.0.0...4.1.0
4.0.0
What's Changed
- ✨
CollapsableItemcan be initialized based on media queries (#34)
If the collapsable element has adata-collapsable-media-queryattribute, its value is used as a condition for initialization. Also, if the media is changed, theCollapsableItemis initialized or destroyed accordingly. This allows it to exist only at specific breakpoints, while at others, the DOM is reverted and remains unmodified. This is particularly useful for components like mobile menus and helps resolve accessibility issues where an item had ahiddenattribute but was later made visible via CSS.
Full Changelog: 3.8.1...4.0.0
3.8.1
What's Changed
- 🐞 Expand/Collapse events triggered only on state change (#33)
Full Changelog: 3.8.0...3.8.1
3.8.0
What's Changed
- ✨ Allow external links to be a button element (#32). External links for collapsable can now be a
HTMLButtonElementwithdata-collapsable-idattribute. There is also an option to prevent the default action of an external link using either the option (this affects all external links for a particularCollapsable) or thedata-collapsable-prevent-defaultattribute (this affects only a specific external link). - 🛠 Dev dependencies updated.
Full Changelog: 3.7.2...3.8.0
3.7.2
What's Changed
- 🛠 Fixed data attibute name for responsive default expanded items (#31).
Full Changelog: 3.7.1...3.7.2