Fix position when scrolling changing layer order

I’ve just encountered a very strange behaviour which I haven’t seen before.
I have an element that I want to be sticky, so I’m clicking “fix position when scrolling”. The second I do that my layer order changes on its own so that the element which has “fix position…” moves to the bottom of the layer stack and becomes invisible.
I’ve used this functionality many times and I’ve never seen this before…