Problem/Motivation
While working on #3465295: Integrate Top Bar Navigation with Contextual editing it was discovered that the way Navigation handles the Top Bar visibility could be improved since any html markup inside it, even just a simple comment makes it visible.
As part of the work in that issue, that logic was improved. Once the issue was closed, those improvements were lost.
The aim of this issue is to recover those improvements introduced in https://git.drupalcode.org/project/drupal/-/merge_requests/11036/diffs?c... and add them for the future.
Steps to reproduce
Proposed resolution
Improve logic to manage the Navigation Top Bar visibility
Remaining tasks
Create MR bringing those improvements that were lost when the original issue was closed.