diff --git a/CHANGELOG.md b/CHANGELOG.md index 30c8c55..13e6e0c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 1.5.3 - 2024-03-21 + +- Add `aria-expanded="false"` attribute to button on init and remove it on destroy for Toggle class. + ## 1.5.2 - 2024-01-23 - Fix closed Modal focusable elements diff --git a/package.json b/package.json index a216b2d..f3ac6cf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@beapi/be-a11y", - "version": "1.5.2", + "version": "1.5.3", "type": "module", "description": "Collection of usefull accessible components", "repository": { diff --git a/src/classes/Toggle.js b/src/classes/Toggle.js index 6ca255f..9d1e616 100644 --- a/src/classes/Toggle.js +++ b/src/classes/Toggle.js @@ -48,6 +48,8 @@ class Toggle extends AbstractDomElement { this.initialized = true + el.setAttribute('aria-expanded', 'false') + if (this.target) { el.addEventListener('click', this._handleClick) } else if (!this.target && onClick) { @@ -113,6 +115,7 @@ class Toggle extends AbstractDomElement { this.initialized = false this.reset() + el.removeAttribute('aria-expanded') if (onClick) { el.removeEventListener('click', onClick)