Hi, I have a very similar issue.
But the difference is that my sticky navigation is set to “Hide when scrolling down”.
I tried the above-mentioned code, but it fixes the box-shadow to the top while scrolling down the page.
How to get the box-shadow to appear only when the navigation is visible?