Skip to content

Commit 4d33268

Browse files
committed
refactor: redesign close button
1 parent bf3f6fc commit 4d33268

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

js/src/sidebar.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ const EVENT_SHOWN = `shown${EVENT_KEY}`
5050
const EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`
5151
const EVENT_LOAD_DATA_API = `load${EVENT_KEY}${DATA_API_KEY}`
5252

53+
const SELECTOR_DATA_CLOSE = '[data-coreui-close="sidebar"]'
5354
const SELECTOR_SIDEBAR = '.sidebar'
5455
const SELECTOR_SIDEBAR_TOGGLER = '.sidebar-toggler'
5556

@@ -342,6 +343,11 @@ class Sidebar extends BaseComponent {
342343
this.toggleUnfoldable()
343344
}
344345
})
346+
347+
EventHandler.on(this._element, EVENT_CLICK_DATA_API, SELECTOR_DATA_CLOSE, event => {
348+
event.preventDefault()
349+
this.hide()
350+
})
345351
}
346352

347353
// Static

0 commit comments

Comments
 (0)