Releases: zipper/collapsable.js
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
3.7.1
What's Changed
- ✨ Support for responsive default expanded items (#30). As well as using a class attribute, elements can be expanded by default using
data-collapsable-default-expanded-media. This data attribute should contain a media query string (e.g.(min-width: 992px)), which is then evaluated usingwindow.matchMedia. If it matches, the item will also be expanded by default, regardless of class. It is therefore intended to be used without the default expanded class name.
Full Changelog: 3.6.0...3.7.1
3.6.0
What's Changed
- ✨ The control element for
CollapsableItemis now optional (#27). If there is no control element, you can either expand / collapse the item programmatically from JS, or you can use an external link. - ✨ External link aria attributes added (#28). Collapsable now sets the
roleattribute (if not already present) on the external link. It also sets the appropriate aria attributes -aria-controlsand eitheraria-selected(ifrole="tab"is used) oraria-expanded(if role="button" or noroleis used). - ⚙ Fixed links inside
package.json(#26). - ⚙ Build packages updated (#29).
Full Changelog: 3.5.2...3.6.0