Menu doesn’t close correctly after scrolling to page section

This is correct. I can’t see how you can achieve a proper solution with the 2-click interaction.
Kind of impossible, because your click won’t trigger a new class you could target.
Try a different approach.

If you need further help, I am confident you will achieve your goal with this thread: