You can add this snippet to the `packs/application.js` or wherever appropriate.
```
$(document).ready(function () {
$(".sidebar, #sidebarToggleTop").on('click', function (e) {
$("body").toggleClass("sidebar-toggled");
$(".sidebar").toggleClass("toggled");
if ($(".sidebar").hasClass("toggled")) {
$('.sidebar .collapse').collapse('hide');
};
});
});
```