Bootstrap4 theme menu not working with onpage_menu: true

When

onpage_menu: true

is set in the frontmater of the modular.md. The mobile menu is showing up like expected so that i could navigate to the “sections”. But it is not collapsing, when you click on a menu-link. It stays open. I dont know if this is a bug.
I think the part that handle this is in the modular.twig.html

...
{% set show_onpage_menu = header.onpage_menu == true or header.onpage_menu is null %}
...

{% block javascripts %}
    {% if show_onpage_menu %}
        {% do assets.add('theme://js/singlePageNav.min.js') %}
    {% endif %}
    {{ parent() }}
{% endblock %}

{% block bottom %}
    {{ parent() }}
    {% if show_onpage_menu %}
        <script>
        // singlePageNav initialization & configuration
        $('.navbar-nav').singlePageNav({
            //offset: $('#header').outerHeight(),
            filter: ':not(.external)',
            updateHash: true,
            currentClass: 'active'
        });
        </script>
    {% endif %}
{% endblock %}
...

Can somebody give me a hint how i can solve this
Thank pgrav

On solution with JS is,
('.navbar-nav>li>a').on('click', function(){ (’.navbar-collapse’).collapse(‘hide’);
});
although there is probably a better way?
pgrav

@pgrav This is an issue with Bootstrap itself, which of course is carried over into theme Bootstrap4.

I don’t know of a better way. I’ve only found solutions which are similar/equal to yours.

It might be an idea to open an issue at the repo of this theme and ask if they could implement the solution. Or maybe create a pull request…