Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed highlight of side nav items on search results page [WD-2276] #4682

Merged
merged 1 commit into from
Mar 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions webapp/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,17 @@ def global_template_context():
version_parts = VANILLA_VERSION.split(".")
version_minor = f"{version_parts[0]}.{version_parts[1]}"

docs_slug = (
flask.request.path.replace("/docs/", "")
.replace("/design/", "")
.replace("/accessibility", "")
)
# Add an exception for the /docs/search path
if flask.request.path == "/docs/search":
docs_slug = ""
else:
docs_slug = (
flask.request.path.replace("/docs/", "")
.replace("/design/", "")
.replace("/accessibility", "")
)

docs_slug = "" if docs_slug == "/docs" else docs_slug
docs_slug = "" if docs_slug == "/docs" else docs_slug
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not add the exception here, where we already have a "/docs exception

Not sure if that would work but something like:

docs_slug = "" if docs_slug == "/docs" or docs_slug == "/docs/search" else docs_slug

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was the first thing that I tried, but actually the /docs/ part of the path gets already replaced one instruction before:

        docs_slug = (
            flask.request.path.replace("/docs/", "")
            .replace("/design/", "")
            .replace("/accessibility", "")
        )

so this condition: docs_slug == "/docs/search" will never be matched.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, right!


# Read navigation.yaml
with open("component_tabs.yaml") as component_tabs_file:
Expand Down