Smarter detection of the active navigation element.