How to automatically open the side navigation dropdown bar when scrolling to a section

Hello, Dear
Hope you are doing well
I had created the sidebar using the dropdown. However, having no idea how to make it open when scrolling to sections.
I want like this side bar.

Thank you in advance for your answer