I had exactly the same issue.
I could solve it by adding a script (let's call it flyout.js
) to my docs/source/_static
directory:
$(document).ready(function() {
var dropdownToggle = $('.sidebar-nav li a.has-dropdown');
dropdownToggle.on('click', function(e) {
e.preventDefault();
var thisLink = $(this);
var thisParent = thisLink.parent();
if (thisParent.hasClass('open')) {
thisParent.removeClass('open');
} else {
$('.sidebar-nav li').removeClass('open');
thisParent.addClass('open');
}
});
$(document).on('click', function(e) {
if (!$(e.target).closest('.sidebar-nav li').length) {
$('.sidebar-nav li').removeClass('open');
}
});
});
This scripts gets the flyout drop-down and add open/close features to it.
Once done, you have to add a reference to this script to your conf.py
, as well as references to its dependencies:
html_js_files = [
'https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js',
'_static/flyout.js'
]
This worked for me. I have to confess I didn't find this by myself. I was stuck and after a lot of unsuccessful researches I ended up asking ChatGPT. Its answer was not perfect and had inconsistencies, but at least it led me to this (which is, when you think of it, somewhat unbelievable).