Fix advanced menu up key in category sorting corner case

Fixes issues #8014 and #7700
Made the advanced inventory selector behave as expected when going up
into a page that happens to end in a category header in sort by category
mode.