Skip to content

Implement top navigation tabs (#6354) #6394

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

Merged
merged 8 commits into from
May 13, 2025
Merged

Conversation

letzya
Copy link
Collaborator

@letzya letzya commented May 9, 2025

Preview

https://deploy-preview-6394--tyk-docs.netlify.app/docs/nightly

  • Add anchor URLs to tabs and fix second-level right-nav accordion
  • Added support for anchor URLs in tabs to enable direct linking.
  • Fixed an issue where second-level items in the right-hand navigation accordion would not close correctly when toggled.
  • Feature/old tabs to docs fixes dmytro a (Docker cloud deployment #2)

  • add anchor URLs to tabs and fix second-level right-nav accordion behavior

  • Added support for anchor URLs in tabs to enable direct linking.
  • Fixed an issue where second-level items in the right-hand navigation accordion would not close correctly when toggled.
  • Add responsive scrollable tabs menu
  • Add horizontal scrolling for tab navigation
  • Make tabs sticky on mobile devices
  • Hide scrollbars for cleaner UI
  • Add active tab indicator with purple underline on mobile
  • Ensure tabs are accessible and visible while scrolling
  • improve mobile navigation tabs
  • Add box shadow to tabs container for better visual hierarchy
  • Adjust padding and font size for better mobile readability
  • Optimize mobile layout with proper spacing
  • Remove horizontal scrolling on mobile devices
  • pdate homepage and menu structure to match v5.5 style
  • Remove unnecessary line above first label
  • Set "home" as first tab without navigation (v5.5 style)
  • Move "overview" tab content to API management tab
  • Implement content for "AI management" and "API governance" tabs
  • Fix TOC active item detection
  • Adjusted headerHeight in getHighestHeading() to better compensate for the fixed header and tabs menu.
  • improve navigation and scrolling behavior
  • Made the version selector dropdown in the left-side navigation always visible (fixed position), matching the live site behavior.
  • Fixed issue where switching to the "API Management" tab caused the page to scroll down by 16–32px.
  • Fixed issue where clicking any item in the right-side navigation menu caused the top header (with Tyk logo and cloud button) to scroll down.
  • Improved alignment of the first tab ("Home") with the sidebar label.
  • Removed bottom margin from tabs and merged the active tab's bold purple underline with the header's bottom border for a seamless look.
  • improve tab menu and sidebar behavior
  • Fix tab menu to stay active when navigating child pages
  • Add recursive descendant check to properly detect active tab state
  • Update menu_recursive.html to show all levels of nested items
  • Fix sidebar navigation to properly expand when parent tab is active
  • clean up

  • Fix active top-level tab highlighting and left navigation rendering

  • Updated tabs_menu.html to correctly determine the active top-level tab when navigating to nested subpages.
  • Added deeper menu traversal to ensure the correct tab is highlighted for all child pages.
  • Fixed an issue where the left navigation would disappear on nested pages.
  • Cleanup: simplify and fix top tabs highlighting logic.

Now only Home is active on the homepage; on other pages, the tab matching the path is active.

  • Refactor menu structure and fix banner overlap
  • Moved "Developer Support" section under "API Management" tab in menu.yaml
  • Removed "Developer Support" from the top-level menu
  • Changed the category of "Developer Support" from Lab to Label
  • Fixed the issue with the banner overlapping content
  • fix: ensure only one active tab in main navigation
  • Improved tab path matching logic to avoid partial matches (e.g. /api-management no longer matches /ai-management)
  • Now only the correct tab is marked as active based on the current page path
  • Fixes issue with multiple tabs being highlighted at once
  • resolve header and search bar overlap with banner, remove Hubspot styles
  • Fixed navigation and search bar so they are no longer overlapped by the banner
  • Prevented the search bar and tabs from shifting under the banner while scrolling
  • Removed all Hubspot banner-related styles and code

Preview Link

Checklist

  • Added a preview link
  • Reviewed AI PR Agent suggestions
  • For Tyk Members - Added Jira DX PR ticket to the subject
  • For Tyk Members - Added the appropriate release labels (for fixes add the latest release)

New Contributors

* test word to delete it latter

* Add anchor URLs to tabs and fix second-level right-nav accordion

- Added support for anchor URLs in tabs to enable direct linking.
- Fixed an issue where second-level items in the right-hand navigation accordion would not close correctly when toggled.

* Feature/old tabs to docs fixes dmytro a (#2)

* add anchor URLs to tabs and fix second-level right-nav accordion behavior

- Added support for anchor URLs in tabs to enable direct linking.
- Fixed an issue where second-level items in the right-hand navigation accordion would not close correctly when toggled.

* clean up

* Add responsive scrollable tabs menu

- Add horizontal scrolling for tab navigation
- Make tabs sticky on mobile devices
- Hide scrollbars for cleaner UI
- Add active tab indicator with purple underline on mobile
- Ensure tabs are accessible and visible while scrolling

* improve mobile navigation tabs

- Add box shadow to tabs container for better visual hierarchy
- Adjust padding and font size for better mobile readability
- Optimize mobile layout with proper spacing
- Remove horizontal scrolling on mobile devices

* pdate homepage and menu structure to match v5.5 style

- Remove unnecessary line above first label
- Set "home" as first tab without navigation (v5.5 style)
- Move "overview" tab content to API management tab
- Implement content for "AI management" and "API governance" tabs

* Fix TOC active item detection

- Adjusted headerHeight in getHighestHeading() to better compensate for the fixed header and tabs menu.

* improve navigation and scrolling behavior

- Made the version selector dropdown in the left-side navigation always visible (fixed position), matching the live site behavior.
- Fixed issue where switching to the "API Management" tab caused the page to scroll down by 16–32px.
- Fixed issue where clicking any item in the right-side navigation menu caused the top header (with Tyk logo and cloud button) to scroll down.
- Improved alignment of the first tab ("Home") with the sidebar label.
- Removed bottom margin from tabs and merged the active tab's bold purple underline with the header's bottom border for a seamless look.

* improve tab menu and sidebar behavior

- Fix tab menu to stay active when navigating child pages
- Add recursive descendant check to properly detect active tab state
- Update menu_recursive.html to show all levels of nested items
- Fix sidebar navigation to properly expand when parent tab is active

* clean up

* Fix active top-level tab highlighting and left navigation rendering

- Updated tabs_menu.html to correctly determine the active top-level tab when navigating to nested subpages.
- Added deeper menu traversal to ensure the correct tab is highlighted for all child pages.
- Fixed an issue where the left navigation would disappear on nested pages.

* Cleanup: simplify and fix top tabs highlighting logic.

Now only Home is active on the homepage; on other pages, the tab matching the path is active.

* Refactor menu structure and fix banner overlap

- Moved "Developer Support" section under "API Management" tab in menu.yaml
- Removed "Developer Support" from the top-level menu
- Changed the category of "Developer Support" from Lab to Label
- Fixed the issue with the banner overlapping content

* fix: ensure only one active tab in main navigation

- Improved tab path matching logic to avoid partial matches (e.g. /api-management no longer matches /ai-management)
- Now only the correct tab is marked as active based on the current page path
- Fixes issue with multiple tabs being highlighted at once

* resolve header and search bar overlap with banner, remove Hubspot styles

- Fixed navigation and search bar so they are no longer overlapped by the banner
- Prevented the search bar and tabs from shifting under the banner while scrolling
- Removed all Hubspot banner-related styles and code

---------

Co-authored-by: dmitry <dmitry@antonyuk.org>
Co-authored-by: Master <sharadregoti15@gmail.com>
Copy link
Contributor

github-actions bot commented May 9, 2025

⚠️ Deploy preview for PR #6394 did not become live after 3 attempts.
Please check Netlify or try manually: Preview URL

Copy link

netlify bot commented May 9, 2025

PS. Pls add /docs/nightly to the end of url

Name Link
🔨 Latest commit c50bbf6
🔍 Latest deploy log https://app.netlify.com/sites/tyk-docs/deploys/68234b373890d7000937ffe0
😎 Deploy Preview https://deploy-preview-6394--tyk-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@letzya
Copy link
Collaborator Author

letzya commented May 9, 2025

/prob "could you please review this pr"

@letzya letzya assigned letzya and unassigned letzya May 9, 2025
@yurisasuke yurisasuke marked this pull request as ready for review May 12, 2025 07:05
@yurisasuke yurisasuke self-requested a review May 12, 2025 07:05
Copy link
Contributor

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

2 - Partially compliant

Compliant requirements:

  • None

Non-compliant requirements:

  • Consider documenting how to install Tyk on Docker Cloud, as suggested by a user in the linked community post.
  • Evaluate whether to add this information to the docs.

Requires further human verification:

  • None
⏱️ Estimated effort to review: 5 🔵🔵🔵🔵🔵
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Increased Complexity

The recursive logic for menu rendering has become significantly more complex, with deep nesting and multiple levels of active state checks. This increases the risk of subtle bugs and makes future maintenance harder. Review for correctness and consider refactoring for readability.

{{- $page := .page -}}
{{- $site := .site -}}
{{- $showEmptyPages := $site.Params.showEmptyPages -}}
{{- $pattern := `\/docs\/\d+\.\d+` -}}
{{- $pagePath := replaceRE $pattern "" $page.RelPermalink -}}
{{- $pagePath := replace $pagePath "/docs" "" -}}
{{- $pagePath := replace $pagePath "/nightly" "" -}}
{{- $pagePath := replace $pagePath "/" "" -}}
{{- $parentActive := .parent_active | default false -}}
{{- $isHome := eq $pagePath "" -}}

{{- if not $isHome -}}
<ul>
  {{- range $index, $item := .menu -}}
    {{- $is := false -}}
    {{- $has := false -}}
    {{- $isActiveParent := false -}}

    {{- $path := replace $item.path "/" "" -}}
    {{- if eq $path $pagePath -}}
      {{- $is = true -}}
      {{- $isActiveParent = true -}}
    {{- end -}}

    {{- if (isset $item "menu") -}}
      {{- range $child := $item.menu -}}
        {{- $childPath := replace $child.path "/" "" -}}
        {{- if eq $childPath $pagePath -}}
          {{- $has = true -}}
          {{- $isActiveParent = true -}}
        {{- end -}}
        {{- if (isset $child "menu") -}}
          {{- range $grandChild := $child.menu -}}
            {{- $grandChildPath := replace $grandChild.path "/" "" -}}
            {{- if eq $grandChildPath $pagePath -}}
              {{- $has = true -}}
              {{- $isActiveParent = true -}}
            {{- end -}}
            {{- if (isset $grandChild "menu") -}}
              {{- /* Recursively check deeper levels */ -}}
              {{- $greatGrandHas := false -}}
              {{- range $greatGrandChild := $grandChild.menu -}}
                {{- $greatGrandChildPath := replace $greatGrandChild.path "/" "" -}}
                {{- if eq $greatGrandChildPath $pagePath -}}
                  {{- $has = true -}}
                  {{- $isActiveParent = true -}}
                  {{- $greatGrandHas = true -}}
                {{- end -}}
                {{- if (isset $greatGrandChild "menu") -}}
                  {{- $fifthLevelHas := false -}}
                  {{- range $fifthLevelChild := $greatGrandChild.menu -}}
                    {{- $fifthLevelChildPath := replace $fifthLevelChild.path "/" "" -}}
                    {{- if eq $fifthLevelChildPath $pagePath -}}
                      {{- $has = true -}}
                      {{- $isActiveParent = true -}}
                      {{- $greatGrandHas = true -}}
                      {{- $fifthLevelHas = true -}}
                    {{- end -}}
                    {{- if (isset $fifthLevelChild "menu") -}}
                      {{- $sixthLevelHas := false -}}
                      {{- range $sixthLevelChild := $fifthLevelChild.menu -}}
                        {{- $sixthLevelChildPath := replace $sixthLevelChild.path "/" "" -}}
                        {{- if eq $sixthLevelChildPath $pagePath -}}
                          {{- $has = true -}}
                          {{- $isActiveParent = true -}}
                          {{- $greatGrandHas = true -}}
                          {{- $fifthLevelHas = true -}}
                          {{- $sixthLevelHas = true -}}
                        {{- end -}}
                      {{- end -}}
                      {{- if $sixthLevelHas -}}
                        {{- $has = true -}}
                        {{- $isActiveParent = true -}}
                        {{- $greatGrandHas = true -}}
                        {{- $fifthLevelHas = true -}}
                      {{- end -}}
                    {{- end -}}
                  {{- end -}}
                  {{- if $fifthLevelHas -}}
                    {{- $has = true -}}
                    {{- $isActiveParent = true -}}
                    {{- $greatGrandHas = true -}}
                  {{- end -}}
                {{- end -}}
              {{- end -}}
              {{- if $greatGrandHas -}}
                {{- $has = true -}}
                {{- $isActiveParent = true -}}
              {{- end -}}
            {{- end -}}
          {{- end -}}
        {{- end -}}
      {{- end -}}
    {{- end -}}

    {{- if eq $pagePath "" -}}
      {{- $is = false -}}
      {{- $has = false -}}
    {{ end }}

    {{- $active := or $is $isActiveParent $parentActive $has -}}
    {{- $shouldShowChildren := or $active $is -}}

    {{- if and (isset $item "menu") (ne $item.category "Label") (ne $item.category "Tab") -}}
      <li class="category-{{ $item.category }} {{ if or $is $has }}st-open{{ else }}st-collapsed{{ end }}">
        {{- if $item.path -}}
          {{- $prefixPath := strings.TrimLeft "/" $item.path -}}
          {{- if eq $item.category "Directory" -}}
            <a href="{{ $prefixPath | relURL }}" class="directory-link {{ if not $item.show }}paint-red{{ end }}">{{- $item.title -}}</a>
          {{- else -}}
            <a href="{{ $prefixPath | relURL }}" class="{{ if $is }}active{{ end }} {{ if not $item.show }}paint-red{{ end }}">{{- $item.title -}}</a>
          {{- end -}}
        {{- else -}}
          <a class="{{ if $is }}active{{ end }} {{ if not $item.show }}paint-red{{ end }}">{{- $item.title -}}</a>
        {{- end -}}
        {{- if $shouldShowChildren -}}
          {{- partial "menu_recursive.html" (dict "menu" $item.menu "page" $page "site" $site "parent_active" $active) -}}
        {{- end -}}
      </li>
    {{- else if and ($item.show) (or (eq $item.category "Label") (eq $item.category "Tab")) -}}
      {{- if or $active (and $isHome (eq $item.title "Home")) -}}
        {{- if eq $item.category "Label" -}}
          {{- if ne $index 0 }}<hr />{{- end }}
          <h6 style="font-size: 15px;">{{ $item.title }}</h6>
        {{- end -}}
        <h6 style="font-size: 15px;" class="sidebar-tab-title">{{ $item.title }}</h6>
        {{- if or $active -}}
          {{- partial "menu_recursive.html" (dict "menu" $item.menu "page" $page "site" $site "parent_active" true) -}}
        {{- end -}}
      {{- end -}}
    {{- else if and ($item.show) (eq $item.category "Tab") -}}
      <h6 class="sidebar-tab-title">{{ $item.title }}</h6>
      {{- if $item.menu -}}
        {{- partial "menu_recursive.html" (dict "menu" $item.menu "page" $page "site" $site "parent_active" $active) -}}
      {{- end -}}
    {{- else -}}
      {{ if or $active -}}
        <li class="st-file {{ if $is }}active{{ end }} {{ if not $item.show }}paint-red{{ end }}">
          {{- $prefixPath := strings.TrimLeft "/" $item.path -}}
          {{- $prefixPath := strings.TrimRight "/" $item.path -}}
          {{- $prefixPath := replace $prefixPath "--" "-&-" -}}
          {{- $prefixMD := printf "%s.md" $prefixPath -}}

          {{- if $prefixPath -}}
            <a href="{{ ref $page $prefixMD }}" class="{{ if $is }}active{{ end }} {{ if not $item.show }}paint-red{{ end }}">{{- $item.title -}}</a>
          {{- else -}}
            {{- $item.title -}}
          {{- end -}}

          {{ if not $item.path }}
            {{- warnf "Found page without path %q" $item.title -}}
          {{ end }}
        </li>
      {{- end -}}
    {{- end -}}
  {{- end -}}
</ul>
{{- end -}}
<style>
Major Menu Structure Refactor

The navigation menu structure has been heavily refactored, introducing new categories (Tab, Label, Directory) and reorganizing content. This could impact navigation, links, and user experience. Carefully review for broken links, missing pages, and correct categorization.

# yamllint disable rule:line-length rule:truthy
---
menu:
  - title: "Home"
    path: /
    category: Tab
    show: True
  - title: "API Management"
    path: /getting-started
    category: Tab
    show: True
    menu:
      - title: "Overview"
        category: Label
        show: True
        menu:
          - title: "Tyk Overview"
            path: /tyk-overview
            category: Page
            show: True
          - title: "Tyk Components"
            path: /tyk-components
            category: Page
            show: True
          - title: "Deployment Options"
            path: /apim
            category: Page
            show: True
          - title: "Plan Your API Integration"
            path: /plan-your-api-integration
            category: Page
            show: True
      - title: "Getting Started"
        category: Label
        show: True
        menu:
          - title: "Create Account"
            path: /getting-started/create-account
            category: Page
            show: True
          - title: "Configure Your First API"
            path: /getting-started/configure-first-api
            category: Page
            show: True
          - title: "Using Tyk Dashboard"
            path: /getting-started/using-tyk-dashboard
            category: Page
            show: True
      - title: "Overview"
        path: /getting-started
        category: Page
        show: True
      - title: "Deploy Tyk"
        category: Directory
        show: True
        menu:
          - title: "Tyk Stack"
            path: /tyk-stack
            category: Page
            show: True
          - title: "Tyk Cloud"
            path: /tyk-cloud
            category: Page
            show: True
          - title: "Tyk Open Source"
            path: /tyk-open-source
            category: Page
            show: True
          - title: "Tyk Self Managed"
            path: /tyk-self-managed
            category: Page
            show: True
      - title: "Tyk Gateway"
        path: /tyk-oss-gateway
        category: Page
        show: True
      - title: "Client Authentication"
        category: Directory
        path: /api-management/client-authentication
        show: True
        menu:
        - title: "Bearer Tokens"
          path: /api-management/authentication/bearer-token
          category: Page
          show: True
        - title: "Basic Authentication"
          path: /api-management/authentication/basic-authentication
          category: Page
          show: True
        - title: "OAuth 2.0"
          path: /api-management/authentication/oauth-2
          category: Page
          show: True
        - title: "JSON Web Tokens"
          path: /basic-config-and-security/security/authentication-authorization/json-web-tokens
          category: Page
          show: True
        - title: "HMAC Signatures"
          path: /basic-config-and-security/security/authentication-authorization/hmac-signatures
          category: Page
          show: True
      - title: "Upstream Authentication"
        path: /api-management/upstream-authentication
        category: Page
        show: True
      - title: "API Traffic Control"
        category: Directory
        show: True
        menu:
        - title: "Rate Limiting"
          path: /api-management/rate-limit
          category: Page
          show: True
        - title: "Request Quotas"
          path: /api-management/request-quotas
          category: Page
          show: True
        - title: "Request Throttling"
          path: /api-management/request-throttling
          category: Page
          show: True
      - title: "Security Policy and Access Keys"
        path: /api-management/policies
        category: Page
        show: True
      - title: "Certificates"
        path: /api-management/certificates
        category: Page
        show: True
      - title: "Security Best Practices"
        category: Page
        show: True
        path: /api-management/security-best-practices
      - title: "Security Features"
        category: Page
        show: True
        path: /api-management/security-features
      - title: "Tyk API Definitions"
        category: Directory
        path: /api-management/gateway-config-introduction
        show: True
        menu:
          - title: "Tyk OAS"
            path: /api-management/gateway-config-tyk-oas
            category: Page
            show: True
          - title: "Tyk Classic"
            path: /api-management/gateway-config-tyk-classic
            category: Page
            show: True
          - title: "What is URL path matching?"
            path: /getting-started/key-concepts/url-matching
            category: Page
            show: True
          - title: "What is Internal Looping?"
            path: /advanced-configuration/transform-traffic/looping
            category: Page
            show: True
      - title: "Manage APIs"
        category: Directory
        show: True
        menu:
          - title: "Tyk OAS APIs"
            path: /api-management/gateway-config-managing-oas
            category: Page
            show: True
          - title: "Tyk Classic APIs"
            path: /api-management/gateway-config-managing-classic
            category: Page
            show: True
          - title: "Migrate from Tyk Classic"
            path: /api-management/migrate-from-tyk-classic
            category: Page
            show: True            
          - title: "Deploy APIs"
            category: Page
            show: True
            path: /api-management/manage-apis/deploy-apis/deploy-apis-overview
          - title: "Useful Configurations"
            path: /tyk-stack/tyk-gateway/important-prerequisites
            category: Page
            show: True
          - title: "Monitoring and Troubleshooting APIs"
            category: Page
            show: True
            path: /api-management/manage-apis/api-operations/api-observability
      - title: "Manage Tyk Dashboard"
        path: /api-management/dashboard-configuration
        category: Page
        show: True
      - title: "API Versioning"
        path: /api-management/api-versioning
        category: Page
        show: True
      - title: "Identity Management"
        path: /api-management/external-service-integration
        category: Page
        show: True
      - title: "Custom Plugins"
        category: Directory
        show: True
        menu:
          - title: "Overview"
            path: /api-management/plugins/overview
            category: Page
            show: True
          - title: "Plugin Types"
            path: /api-management/plugins/plugin-types
            category: Page
            show: True
          - title: "Golang Plugins"
            path: /api-management/plugins/golang
            category: Page
            show: True
          - title: "Javscript Plugins"
            path: /api-management/plugins/javascript
            category: Page
            show: True
          - title: "Rich Plugins"
            path: /api-management/plugins/rich-plugins
            category: Page
            show: True
          - title: "Advance Configuration"
            path: /api-management/plugins/advance-config
            category: Page
            show: True
      - title: "Event Driven APIs"
        category: Directory
        show: True
        menu:
        - title: "Tyk Streams"
          path: /api-management/event-driven-apis
          category: Page
          show: True
        - title: "Tyk Streams Reference"
          path: /api-management/stream-config
          category: Page
          show: True
      - title: "GraphQL"
        path: /api-management/graphql
        category: Page
        show: True
      - title: "Universal Data Graph (UDG)"
        path: /api-management/data-graph
        category: Page
        show: True
      - title: "TCP Proxy"
        path: /key-concepts/tcp-proxy
        category: Page
        show: True
      - title: "Other Non HTTP Protocols"
        path: /api-management/non-http-protocols
        category: Page
        show: True
      - title: "Request Optimization"
        category: Directory
        show: True
        menu:
        - title: "Response Caching"
          path: /api-management/response-caching
          category: Page
          show: True
        - title: "Batch Processing"
          path: /api-management/batch-processing
          category: Page
          show: True
      - title: "API Observability"
        category: Directory
        show: True
        menu:
          - title: "Metrics and Logs"
            path: /api-management/logs-metrics
            category: Page
            show: True
          - title: "Metrics Exporter"
            path: /api-management/tyk-pump
            category: Page
            show: True
          - title: "Performance Monitoring"
            path: /api-management/performance-monitoring
            category: Page
            show: True
      - title: "Traffic Transformation"
        category: Directory
        show: True
        menu:
        - title: "Overview"
          path: /api-management/traffic-transformation
          category: Page
          show: True
        - title: "SOAP to REST"
          path: /advanced-configuration/transform-traffic/soap-rest
          category: Page
          show: True
        - title: "URL Rewrite"
          path: /transform-traffic/url-rewriting
          category: Page
          show: True
      - title: "Gateway Events"
        path: /api-management/gateway-events
        category: Page
        show: True
      - title: "Manage Distributed Gateways"
        path: /api-management/mdcb
        category: Page
        show: True
      - title: "Automations Tools"
        category: Directory
        show: True
        menu:
          - title: "Overview"
            path: /api-management/automations
            category: Page
            show: True
          - title: "API Management in Kubernetes"
            path: /api-management/automations/operator
            category: Page
            show: True
          - title: "Synchronizing Tyk Configuration"
            path: /api-management/automations/sync
            category: Page
            show: True
      - title: "Manage Environments"
        path: /api-management/multiple-environments
        category: Page
        show: True
      - title: "Tyk Helm Charts"
        category: Directory
        show: True
        menu:
          - title: "Overview"
            path: /product-stack/tyk-charts/overview
            category: Page
            show: True
          - title: "Tyk Stack Chart"
            path: /product-stack/tyk-charts/tyk-stack-chart
            category: Page
            show: True
          - title: "Tyk Control Plane Chart"
            path: /product-stack/tyk-charts/tyk-control-plane-chart
            category: Page
            show: True
          - title: "Tyk Data Plane Chart"
            path: /product-stack/tyk-charts/tyk-data-plane-chart
            category: Page
            show: True
          - title: "Tyk Open Source Chart"
            path: /product-stack/tyk-charts/tyk-oss-chart
            category: Page
            show: True
      - title: "User Management"
        path: /api-management/user-management
        category: Page
        show: True
      - title: "Troubleshooting"
        path: /api-management/troubleshooting-debugging
        category: Page
        show: True
      - title: "Developer Support"
        category: Label
        show: True
        path: /developer-support/community
        menu:
          - title: "Community Support"
            path: /developer-support/community
            category: Page
            show: True
          - title: "Support SLA"
            path: /developer-support/support
            category: Page
            show: True
          - title: "Tyk Release Types"
            category: Directory
            show: True
            menu:
              - title: "Long Term Support Release"
                path: /developer-support/release-types/long-term-support
                category: Page
                show: True
              - title: "Early access feature"
                path: /developer-support/release-types/early-access-feature
                category: Page
                show: True
              - title: "Lab Release"
                path: /developer-support/release-types/lab-release
                category: Page
                show: True
              - title: "FIPS Release"
                path: /developer-support/release-types/fips-release
                category: Page
                show: True
          - title: "Environment Variables and Configs"
            category: Directory
            show: True
            menu:
            - title: "Gateway"
              path: /tyk-oss-gateway/configuration
              category: Page
              show: True
            - title: "Dashboard"
              path: /tyk-dashboard/configuration
              category: Page
              show: True
            - title: "Pump"
              path: /tyk-pump/tyk-pump-configuration/tyk-pump-environment-variables
              category: Page
              show: True
            - title: "Enterprise Developer Portal"
              path: /product-stack/tyk-enterprise-developer-portal/deploy/configuration
              category: Page
              show: True
            - title: "Multi Data Center Bridge"
              path: /tyk-multi-data-centre/mdcb-configuration-options
              category: Page
              show: True
            - title: "Tyk Identity Broker"
              path: /tyk-configuration-reference/tyk-identity-broker-configuration
              category: Page
              show: True
          - title: "API Documentation"
            category: Directory
            show: True
            menu:
            - title: "Overview"
              path: /tyk-apis
              category: Page
              show: True
            - title: "Gateway"
              path: /tyk-gateway-api
              category: Page
              show: True
            - title: "Dashboard"
              path: /tyk-dashboard-api
              category: Page
              show: True
            - title: "Dashboard Admin"
              path: /dashboard-admin-api
              category: Page
              show: True
            - title: "Multi Data Center Bridge"
              path: /tyk-mdcb-api
              category: Page
              show: True
            - title: "Enterprise Developer Portal"
              path: /product-stack/tyk-enterprise-developer-portal/api-documentation/tyk-edp-api
              category: Page
              show: True
            - title: "Enterprise Developer Portal Admin"
              path: /product-stack/tyk-enterprise-developer-portal/api-documentation/list-of-endpoints/portal-1.13.0-list-of-endpoints
              category: Page
              show: True
            - title: "Tyk Identity Broker"
              path: /tyk-identity-broker/tib-rest-api
              category: Page
              show: True
          - title: "Release Notes"
            category: Directory
            show: True
            menu:
            - title: "Latest Tyk Releases"
              path: /developer-support/release-notes/overview
              category: Page
              show: True
            - title: "Gateway"
              path: /developer-support/release-notes/gateway
              category: Page
              show: True
            - title: "Dashboard"
              path: /developer-support/release-notes/dashboard
              category: Page
              show: True
            - title: "Pump"
              path: /developer-support/release-notes/pump
              category: Page
              show: True
            - title: "Sync"
              path: /developer-support/release-notes/sync
              category: Page
              show: True
            - title: "Multi Data Center Bridge"
              path: /developer-support/release-notes/mdcb
              category: Page
              show: True
            - title: "Enterprise Developer Portal"
              path: /developer-support/release-notes/portal
              category: Page
              show: True
            - title: "Tyk Operator"
              path: /developer-support/release-notes/operator
              category: Page
              show: True
            - title: "Tyk Chart"
              path: /developer-support/release-notes/helm-chart
              category: Page
              show: True
            - title: "Tyk Identity Broker"
              path: /developer-support/release-notes/tib
              category: Page
              show: True
            - title: "Tyk Cloud"
              path: /developer-support/release-notes/cloud
              category: Page
              show: True
            - title: "Archived Releases"
              path: /developer-support/release-notes/archived
              category: Page
              show: True
          - title: "Deprecation"
            path: /developer-support/deprecation
            category: Page
            show: True
          - title: "Upgrading Guide"
            path: /developer-support/upgrading
            category: Page
            show: True
          - title: "Frequently Asked Questions"
            path: /developer-support/faq
            category: Page
            show: True
          - title: "Docs Contribution"
            path: /developer-support/contributing
            category: Directory
            show: True
            menu:
              - title: "UI Example: Pill Label shortcode"
                path: /ui-examples/test-pill-label
                category: Page
                show: true
              - title: "UI Example: Feature Cards shortcode"
                path: /ui-examples/feature-cards
                category: Page
                show: true
              - title: "UI Example: YouTube Video Embed shortcode"
                path: /ui-examples/youtube-video-embed
                category: Page
                show: true
  - title: "Developer Portal"
    category: Tab
    show: True
    path: /portal/overview
    menu:
      - title: "Overview"
        path: /portal/overview
        category: Page
        show: True
      - title: "Install and Configure"
        path: /portal/install
        category: Page
        show: True
      - title: "API Consumer"
        path: /portal/api-consumer
        category: Directory
        show: True
        menu:
        - title: "Invite Codes"
          path: /portal/api-consumer/invite-codes
          category: Page
          show: True
      - title: "API Provider"
        path: /portal/api-provider
        category: Page
        show: True
      - title: "Customization"
        path: /portal/customization
        category: Page
        show: True
      - title: "Advance Configuration"
        path: /portal/settings
        category: Page
        show: True
      - title: "Tyk Classic Developer Portal"
        category: Directory
        show: True
        menu:
          - title: "Overview"
            path: /tyk-developer-portal/tyk-portal-classic
            category: Page
            show: True
          - title: "Portal Concepts"
            path: /tyk-developer-portal/tyk-portal-classic/portal-concepts
            category: Page
            show: True
          - title: "Portal API Catalogue"
            path: /getting-started/key-concepts/api-catalogue
            category: Page
            show: True
          - title: "Publish an API"
            path: /getting-started/tutorials/publish-api
            category: Page
            show: True
          - title: "Advanced configurations"
            category: Directory
            show: True
            menu:
              - title: "Key Requests"
                path: /tyk-developer-portal/tyk-portal-classic/key-requests
                category: Page
                show: True
              - title: "Developer Profiles"
                path: /tyk-developer-portal/tyk-portal-classic/developer-profiles
                category: Page
                show: True
              - title: "Dynamic Client Registration (DCR)"
                category: Directory
                show: True
                menu:
                  - title: "Overview"
                    path: /tyk-developer-portal/tyk-portal-classic/dynamic-client-registration
                    category: Page
                    show: True
                  - title: "Step by step guide using Gluu"
                    path: /tyk-developer-portal/tyk-portal-classic/gluu-dcr
                    category: Page
                    show: True
                  - title: "Step by step guide using Keycloak"
                    path: /tyk-developer-portal/tyk-portal-classic/keycloak-dcr
                    category: Page
                    show: True
                  - title: "Step by step guide using Okta"
                    path: /tyk-developer-portal/tyk-portal-classic/okta-dcr
                    category: Page
                    show: True
                  - title: "Step by step guide using Curity"
                    path: /tyk-developer-portal/tyk-portal-classic/curity-dcr
                    category: Page
                    show: True
              - title: "Portal OAuth Clients"
                path: /tyk-developer-portal/tyk-portal-classic/portal-oauth-clients
                category: Page
                show: True
              - title: "GraphQL with Classic Portal"
                path: /tyk-developer-portal/tyk-portal-classic/graphql
                category: Page
                show: True
              - title: "Streams with Classic Portal"
                path: /tyk-developer-portal/tyk-portal-classic/streams
                category: Page
                show: True
              - title: "Monetising your APIs"
                path: /tyk-developer-portal/tyk-portal-classic/monetise
                category: Page
                show: True
              - title: "Events and Notifications"
                path: /tyk-developer-portal/tyk-portal-classic/portal-events-notifications
                category: Page
                show: True
              - title: "Outbound Email Configuration"
                path: /configure/outbound-email-configuration
                category: Page
                show: True
          - title: "Portal customisation"
            category: Directory
            show: True
            menu:
              - title: "Overview"
                path: /tyk-developer-portal/customise
                category: Page
                show: True
              - title: "Customising API Visibility"
                path: /tyk-developer-portal/customise/customize-api-visibility
                category: Page
                show: True
              - title: "Customise the Portal Menus"
                path: /tyk-developer-portal/tyk-portal-classic/customise/changing-the-navigation
                category: Page
                show: True
              - title: "Creating a Custom Developer Portal"
                path: /tyk-developer-portal/tyk-portal-classic/customise/custom-developer-portal
                category: Page
                show: True
              - title: "Swap out Swagger UI for ReDoc"
                path: /tyk-developer-portal/tyk-portal-classic/customise/customise-documentation
                category: Page
                show: True
              - title: "Customise Pages with CSS and JavaScript"
                path: /tyk-developer-portal/tyk-portal-classic/customise/customising-using-dashboard
                category: Page
                show: True
              - title: "Customising using jQuery"
                path: /tyk-developer-portal/tyk-portal-classic/customise/customize-with-jquery
                category: Page
                show: True
              - title: "Customise the Developer Signup Form"
                path: /tyk-developer-portal/tyk-portal-classic/customise/developer-meta-data
                category: Page
                show: True
              - title: "Customise Page Templates"
                path: /tyk-developer-portal/tyk-portal-classic/tyk-portal-classic/customise/customise-with-templates
                category: Page
                show: True
          - title: "API documentation"
            category: Directory
            show: True
            menu:
              - title: "Overview"
                path: /tyk-portal-api
                category: Page
                show: True
              - title: "Configuration"
                path: /tyk-apis/tyk-portal-api/portal-configuration
                category: Page
                show: True
              - title: "Developers"
                path: /tyk-apis/tyk-portal-api/portal-developers
                category: Page
                show: True
              - title: "API Publishing"
                path: /tyk-apis/tyk-portal-api/portal-documentation
                category: Page
                show: True
              - title: "Key Requests"
                path: /tyk-apis/tyk-portal-api/portal-keys
                category: Page
                show: True
          - title: "Troubleshooting"
            category: Directory
            show: True
            menu:
              - title: "How to add, list or delete a developer using the API"
                path: /frequently-asked-questions/add-list-delete-developer-using-api
                category: Page
                show: True
              - title: "Alerts on new developer key requests"
                path: /frequently-asked-questions/alerts-new-developer-key-requests
                category: Page
                show: True
              - title: "Custom Developer Portal Options"
                path: /frequently-asked-questions/custom-developer-portal-options
                category: Page
                show: True
              - title: "“API catalogue not found“ error in the Developer Portal"
                path: /troubleshooting/tyk-dashboard/api-catalogue-not-found-error-developer-portal
                category: Page
                show: True
              - title: "CORS issues on developer portal"
                path: /troubleshooting/tyk-dashboard/cors-issues-on-developer-portal
                category: Page
                show: True
              - title: "“Not Found“ error in the Developer Portal"
                path: /troubleshooting/tyk-dashboard/not-found-error-developer-portal
                category: Page
                show: True
              - title: "Receive a CSRF error in the Developer Portal"
                path: /troubleshooting/tyk-dashboard/receive-csrf-error-developer-portal
                category: Page
                show: True
          - title: "Dashboard API"
            category: Directory
            show: True
            menu:
              - title: "Classic Portal"
                category: Directory
                show: True
                menu:
                  - title: "Portal Key Requests"
                    path: /tyk-apis/tyk-dashboard-api/manage-key-requests
                    category: Page
                    show: True
                  - title: "Portal Policies"
                    path: /tyk-apis/tyk-dashboard-api/portal-policies
                    category: Page
                    show: True
  - title: "AI Management"
    category: Tab
    path: /ai-management/overview
    show: True
    menu:
      - title: "Overview"
        category: Page
        path: /ai-management/overview
        show: True
      - title: "MCPs"
        path: /ai-management/mcps/overview
        category: Directory
        show: True
        menu:
          - title: "API to MCP"
            category: Page
            path: /ai-management/mcps/api-to-mcp
            show: True
          - title: "Dashboard API to MCP"
            category: Page
            path: /ai-management/mcps/dashboard-api-to-mcp
            show: True
          - title: "Tyk Docs MCP"
            category: Page
            path: /ai-management/mcps/tyk-docs-mcp
            show: True
      - title: "AI Studio"
        path: /ai-management/ai-studio/overview
        category: Directory
        show: True
        menu:
          - title: "Introduction"
            category: Directory
            show: True
            menu:
              - title: "Quickstart"
                category: Page
                path: /ai-management/ai-studio/quickstart
                show: True
              - title: "Core Concepts"
                category: Page
                path: /ai-management/ai-studio/core-concepts
                show: True
          - title: "Getting Started"
            category: Directory
            show: True
            menu:
              - title: "Installation (Helm/K8s)"
                category: Page
                path: /ai-management/ai-studio/deployment-helm-k8s
                show: True
              - title: "Initial Configuration"
                category: Page
                path: /ai-management/ai-studio/configuration
                show: True
          - title: "Core Features"
            category: Directory
            show: True
            menu:
              - title: "AI Gateway"
                category: Page
                path: /ai-management/ai-studio/proxy
                show: True
              - title: "AI Portal"
                category: Page
                path: /ai-management/ai-studio/ai-portal
                show: True
              - title: "Chat Interface"
                category: Page
                path: /ai-management/ai-studio/chat-interface
                show: True
              - title: "LLM Management"
                category: Page
                path: /ai-management/ai-studio/llm-management
                show: True
              - title: "Tools & Extensibility"
                category: Page
                path: /ai-management/ai-studio/tools
                show: True
              - title: "Data Sources & RAG"
                category: Page
                path: /ai-management/ai-studio/datasources-rag
                show: True
              - title: "Filters & Policies"
                category: Page
                path: /ai-management/ai-studio/filters
                show: True
          - title: "Administration"
            category: Directory
            show: True
            menu:
              - title: "User Management & RBAC"
                category: Page
                path: /ai-management/ai-studio/user-management
                show: True
              - title: "SSO Integration"
                category: Page
                path: /ai-management/ai-studio/sso
                show: True
              - title: "Secrets Management"
                category: Page
                path: /ai-management/ai-studio/secrets
                show: True
              - title: "Budget Control"
                category: Page
                path: /ai-management/ai-studio/budgeting
                show: True
              - title: "Analytics & Monitoring"
                category: Page
                path: /ai-management/ai-studio/analytics
                show: True
              - title: "Notifications"
                category: Page
                path: /ai-management/ai-studio/notifications
                show: True
              - title: "API Documentation"
                category: Page
                path: /ai-management/ai-studio/ai-studio-swagger
                show: True
  - title: "API Governance"
    category: Tab
    show: True
    path: /tyk-governance/overview
    menu:
      - title: "Overview"
        path: /tyk-governance/overview
        category: Page
        show: True
      - title: "Core Concepts"
        path: /tyk-governance/core-concepts
        category: Page
        show: True
      - title: "Installation"
        path: /tyk-governance/installation
        category: Page
        show: True
      - title: "Federated API Repository"
        path: /tyk-governance/api-repository
        category: Page
        show: True
      - title: "API Labeling and Categorization"
        path: /tyk-governance/api-labeling
        category: Page
        show: True
Tab Selection Logic

The logic for determining the active tab and its children is intricate and relies on string manipulation and path matching. There is a risk of edge cases where the wrong tab is marked active or links are incorrect. Validate this logic thoroughly.

{{- $pagePath := .Page.RelPermalink -}}
{{- $pagePath := replace $pagePath "/docs" "" -}}
{{- $pagePath := replace $pagePath "/nightly" "" -}}
{{- $showEmptyPages := .Site.Params.showEmptyPages -}}

<div class="tabs-wrapper">
  <div class="tabs-container">
    {{- range .Site.Data.menu.menu -}}
      {{- if eq .category "Tab" -}}
        {{- $selected := false -}}
        {{- $is_home := eq (lower .title) "home" -}}
        {{- $path_not_empty := false -}}
        {{- $tabPath := .path | relURL -}}
        {{- $has_active_child := false -}}

        {{- if or (eq $tabPath $pagePath) (and (ne $tabPath "/") (hasPrefix $pagePath $tabPath) (or (eq (substr $pagePath (len $tabPath) 1) "/") (eq (substr $pagePath (len $tabPath) 1) ""))) -}}
          {{- if or (ne $pagePath "") $is_home -}}
            {{- $selected = true -}}
            {{- $path_not_empty = true -}}
          {{- end -}}
        {{- end -}}

        {{- if (isset . "menu") -}}
          {{- range .menu -}}
            {{- $childPath := .path | relURL -}}
            {{- if or (eq $childPath $pagePath) (and (ne $childPath "/") (hasPrefix $pagePath $childPath) (or (eq (substr $pagePath (len $childPath) 1) "/") (eq (substr $pagePath (len $childPath) 1) ""))) -}}
              {{- if or (ne $pagePath "") $is_home -}}
                {{- $selected = true -}}
                {{- $has_active_child = true -}}
                {{- $path_not_empty = true -}}
              {{- end -}}
            {{- end -}}
            {{- if (isset . "menu") -}}
              {{- range .menu -}}
                {{- $grandChildPath := .path | relURL -}}
                {{- if or (eq $grandChildPath $pagePath) (and (ne $grandChildPath "/") (hasPrefix $pagePath $grandChildPath) (or (eq (substr $pagePath (len $grandChildPath) 1) "/") (eq (substr $pagePath (len $grandChildPath) 1) ""))) -}}
                  {{- if or (ne $pagePath "") $is_home -}}
                    {{- $selected = true -}}
                    {{- $has_active_child = true -}}
                    {{- $path_not_empty = true -}}
                  {{- end -}}
                {{- end -}}
                {{- if (isset . "menu") -}}
                  {{- range .menu -}}
                    {{- $greatGrandChildPath := .path | relURL -}}
                    {{- if or (eq $greatGrandChildPath $pagePath) (and (ne $greatGrandChildPath "/") (hasPrefix $pagePath $greatGrandChildPath) (or (eq (substr $pagePath (len $greatGrandChildPath) 1) "/") (eq (substr $pagePath (len $greatGrandChildPath) 1) ""))) -}}
                      {{- if or (ne $pagePath "") $is_home -}}
                        {{- $selected = true -}}
                        {{- $has_active_child = true -}}
                        {{- $path_not_empty = true -}}
                      {{- end -}}
                    {{- end -}}
                  {{- end -}}
                {{- end -}}
              {{- end -}}
            {{- end -}}
          {{- end -}}
        {{- end -}}

        {{- if or (.show) ($showEmptyPages) -}}
          <div class="tab-item {{if (or $selected $has_active_child)}}nav_sub_active{{end}}">
            {{- if .url -}}
              <a href="{{ .url }}" class="tab-link {{if not .show}} paint-red {{end}} {{if (or $selected $has_active_child)}} active{{end}}">{{- .title -}}</a>
            {{- else -}}
              {{- $prefixPath := strings.TrimLeft "/" .path -}}
              <a href="{{$prefixPath | relURL}}" class="tab-link {{if not .show}} paint-red {{end}} {{if (or $selected $has_active_child)}} active{{end}}">{{- .title -}}</a>
            {{- end -}}
          </div>
        {{- end -}}
      {{- end -}}
    {{- end -}}
  </div>
</div>

Copy link
Contributor

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
General
Remove unnecessary event propagation stop

Using e.stopPropagation() here may prevent other click handlers on parent elements
from firing, potentially breaking expected accordion or navigation behaviors. Remove
e.stopPropagation() unless it is strictly necessary for correct functionality.

tyk-docs/static/js/docs-table-of-contents.js [59-66]

 link.click(function (e) {
     e.preventDefault();
-    e.stopPropagation();
     var $parentContent = $(this).parent('.accordion-content');
     $parentContent.toggleClass("accordion-up");
     // Toggle visibility of H4 elements under this H3
     $parentContent.children('.sub-accordion-content').toggle();
   });
Suggestion importance[1-10]: 6

__

Why: Removing e.stopPropagation() can improve compatibility with other click handlers and is a reasonable suggestion unless there is a specific reason to prevent event bubbling. The change is minor but can help avoid unexpected behavior in complex UI interactions.

Low

@yurisasuke
Copy link
Member

yurisasuke commented May 12, 2025

@letzya @borntojesus
Screenshot 2025-05-12 at 11 15 22
One thing that would be great on mobile tabs is if the active tab was always visible on the screen (centered horizontally).For example in this case the active tab is Ai management but it is hidden.

@yurisasuke
Copy link
Member

/probe

Copy link
Contributor

Code Review: Top Navigation Tabs Implementation

Overview

This PR implements top navigation tabs for the Tyk documentation site, providing a more organized and user-friendly navigation experience. The implementation includes several key features:

  1. Anchor URLs for Tabs: Enables direct linking to specific tabs
  2. Responsive Tab Navigation: Horizontal scrolling for mobile devices with proper styling
  3. Fixed Tab Positioning: Tabs remain visible while scrolling
  4. Active Tab Indication: Clear visual indication of the current active tab
  5. Menu Structure Reorganization: Updated to match v5.5 style

Implementation Details

Tab Structure and Rendering

The tabs are implemented in tabs_menu.html which iterates through menu items with the category "Tab" from the menu.yaml file. The implementation:

  • Uses a recursive approach to determine the active tab based on the current page path
  • Adds proper CSS classes for active states
  • Creates a horizontally scrollable container for mobile devices

CSS Implementation

The styling is defined in _navigation-tabs.scss with key features:

  • Responsive design with different styles for mobile and desktop
  • Horizontal scrolling with hidden scrollbars for a clean UI
  • Visual indicators for active tabs (purple underline on mobile)
  • Hover effects for better user interaction
  • Proper spacing and alignment

JavaScript Functionality

The implementation includes JavaScript enhancements:

  • Fixed an issue with the second-level right-nav accordion not closing correctly
  • Added scroll functionality to ensure the active tab is visible
  • Improved TOC (Table of Contents) active item detection by adjusting the header height

Menu Structure

The menu.yaml file has been reorganized with a clear tab-based structure:

  • Home tab (without navigation, v5.5 style)
  • API Management tab (containing most of the content)
  • Developer Portal tab
  • AI Management tab
  • API Governance tab

Code Quality Assessment

Strengths

  1. Well-structured HTML templates: The templates use proper Hugo templating practices
  2. Clean and maintainable SCSS: The styling is organized and follows best practices
  3. Responsive design: Works well on both desktop and mobile devices
  4. Semantic HTML: Uses appropriate HTML elements for navigation

Areas for Improvement

  1. Complex recursive logic: The menu rendering logic in menu_recursive.html is quite complex with deep nesting, which could make future maintenance challenging
  2. Potential edge cases in path matching: The path matching logic could have edge cases where tabs are incorrectly highlighted
  3. Mobile tab visibility: As noted in a comment, the active tab isn't always visible on mobile (not automatically centered)

Recommendations

  1. Simplify recursive logic: Consider refactoring the deeply nested menu traversal logic for better maintainability
  2. Add automated tests: Add tests to verify tab highlighting works correctly for various URL patterns
  3. Improve mobile experience: Implement auto-scrolling to center the active tab on mobile as suggested in the comment
  4. Remove unnecessary event propagation stop: As noted in the PR comments, e.stopPropagation() in docs-table-of-contents.js could be removed unless strictly necessary

Overall, this is a well-implemented feature that significantly improves the navigation experience for Tyk documentation users. The code is generally well-structured and follows best practices, with a few areas that could be refined for better maintainability.


Tip: Mention me again using /probe <request>.
Powered by Probe AI

@yurisasuke
Copy link
Member

/probe

Copy link
Contributor

Code Review: Top Navigation Tabs Implementation

Overview

This PR implements a new top navigation tab system for the Tyk documentation site, providing a more organized and user-friendly navigation experience. The implementation includes anchor URLs for tabs, responsive design for mobile devices, and improved tab highlighting logic.

Key Features Implemented

  1. Tab Navigation Structure

    • Added a horizontal tab menu at the top of the page with categories: Home, API Management, Developer Portal, AI Management, and API Governance
    • Implemented proper active state detection for tabs with recursive path matching
    • Created a responsive design that works well on both desktop and mobile
  2. Improved User Experience

    • Added support for anchor URLs in tabs to enable direct linking to specific sections
    • Implemented horizontal scrolling for tab navigation on mobile with hidden scrollbars
    • Made tabs sticky on mobile devices (position: sticky) for better navigation while scrolling
    • Added visual indicators for active tabs (purple underline)
  3. Navigation Logic Improvements

    • Fixed the second-level right-nav accordion behavior that wasn't closing correctly
    • Implemented recursive descendant checking to properly detect active tab state across nested pages
    • Updated menu structure to match v5.5 style with "Home" as the first tab without navigation
    • Fixed banner overlap issues with proper z-index and positioning
  4. Technical Implementation

    • Created new SCSS styles in _navigation-tabs.scss with responsive breakpoints
    • Added JavaScript for scrolling active sidebar items into view (scroll_to_active_tab.js)
    • Implemented complex path matching logic in tabs_menu.html to handle nested navigation
    • Reorganized menu structure in menu.yaml with clear tab categories (Tab, Label, Directory, Page)

Code Quality Assessment

Strengths

  1. Well-structured HTML templates: The tab menu implementation uses proper Hugo templating practices with clean conditional logic.
  2. Clean CSS implementation: The styling in _navigation-tabs.scss is well-organized with responsive design considerations and proper variable usage.
  3. Proper active state detection: The implementation correctly identifies and highlights the active tab based on the current page path, even for deeply nested pages.
  4. Performance optimizations: Hidden scrollbars and smooth transitions improve the user experience without sacrificing performance.

Areas for Improvement

  1. Complex recursive logic: The menu rendering logic in menu_recursive.html is quite complex with deep nesting (up to 6 levels), which could make future maintenance challenging.
  2. Path matching edge cases: The path matching logic in tabs_menu.html could potentially have edge cases where tabs are incorrectly highlighted due to partial path matches.
  3. Mobile experience: As noted by @yurisasuke, the active tab isn't always visible on mobile (not automatically centered in the viewport). While there is a scroll_to_active_tab.js script, it only handles scrolling the active sidebar item into view (.st-treed li.active) but doesn't address the top tabs visibility issue.
  4. Event propagation: The PR comments suggest removing e.stopPropagation() in docs-table-of-contents.js as it may prevent other click handlers from firing.

Recommendations

  1. Simplify recursive logic: Consider refactoring the deeply nested menu traversal logic for better maintainability, possibly using a more iterative approach.
  2. Improve mobile experience: Create a similar script or extend scroll_to_active_tab.js to handle the top tabs navigation by adding functionality for .tab-item .tab-link.active elements to ensure the active tab is centered on mobile devices.
  3. Remove unnecessary event propagation stop: Remove e.stopPropagation() in docs-table-of-contents.js unless strictly necessary for accordion functionality.
  4. Add automated tests: Consider adding tests to verify tab highlighting works correctly for various URL patterns to catch edge cases.
  5. Consider accessibility improvements: Ensure the tab navigation is fully keyboard accessible and has proper ARIA attributes for screen readers.

Implementation Example for Mobile Tab Centering

To address the mobile tab visibility issue, a simple addition to scroll_to_active_tab.js could be implemented:

document.addEventListener('DOMContentLoaded', function() {
    // Existing code for sidebar navigation
    const activeItem = document.querySelector('.st-treed li.active');
    if (activeItem) {
        activeItem.scrollIntoView({
            behavior: 'instant',
            block: 'center',
        });
    }
    
    // New code for top tabs navigation
    const activeTab = document.querySelector('.tab-item .tab-link.active');
    if (activeTab) {
        activeTab.scrollIntoView({
            behavior: 'instant',
            block: 'center',
            inline: 'center' // This ensures horizontal centering
        });
    }
});

Overall, this is a well-implemented feature that significantly improves the navigation experience for Tyk documentation users. The code is generally well-structured and follows best practices, with a few areas that could be refined for better maintainability and user experience.


Tip: Mention me again using /probe <request>.
Powered by Probe AI

@yurisasuke
Copy link
Member

@borntojesus For me the active tab on mobile is still not centered (visible).
Screenshot 2025-05-13 at 11 24 46

@yurisasuke
Copy link
Member

* test word to delete it latter
@yurisasuke
Copy link
Member

/probe

Copy link
Contributor

Code Review: Top Navigation Tabs Implementation

Overview

This PR implements a new top navigation tab system for the Tyk documentation site, providing a more organized and user-friendly navigation experience. The implementation includes anchor URLs for tabs, responsive design for mobile devices, and improved tab highlighting logic.

Key Features

  • Added support for anchor URLs in tabs to enable direct linking
  • Fixed second-level right-nav accordion behavior
  • Added responsive scrollable tabs menu for mobile
  • Improved tab menu highlighting for nested pages
  • Fixed banner overlap issues

Mobile Tab Visibility Issue

The most significant issue reported is that on mobile devices, the active tab is not always visible in the viewport. Looking at the current implementation of scroll_tabs_menu.js:

document.addEventListener("DOMContentLoaded", function() {
  var activeTab = document.querySelector('.tab-link.active');
  var container = document.getElementById('tabs-container');
  if (activeTab && container) {
    if (window.innerWidth <= 768) {
      activeTab.scrollIntoView({
        behavior: 'smooth',
        block: 'nearest',
        inline: 'center'
      });
    }
  }
}); 

The script attempts to center the active tab on mobile devices using scrollIntoView() with the inline: 'center' option. However, as demonstrated in the user's video, this is not working correctly.

Root Causes of the Issue

After analyzing the implementation, I've identified several potential reasons why the active tab centering isn't working properly on mobile:

  1. Timing Issues: The script runs on DOMContentLoaded, but the tabs might not be fully rendered or positioned at that point.

  2. Scroll Target Issues: The scrollIntoView() method scrolls the nearest scrollable ancestor, which might not be the tabs container if there are other scrollable elements in the hierarchy.

  3. CSS Interference: There might be CSS rules that affect the scrolling behavior or the positioning of the tabs.

  4. Event Handling Limitations: The script only runs once on page load and doesn't handle window resize events or navigation between tabs without a page reload.

Recommended Solutions

1. Improved Tab Centering Script

Replace the current scroll_tabs_menu.js with this enhanced version:

document.addEventListener("DOMContentLoaded", function() {
  // Function to center the active tab
  function centerActiveTab() {
    const activeTab = document.querySelector('.tab-link.active');
    const tabsContainer = document.getElementById('tabs-container');
    
    if (activeTab && tabsContainer && window.innerWidth <= 768) {
      // Add a small delay to ensure elements are fully rendered
      setTimeout(() => {
        // Method 1: Use scrollIntoView with inline center
        activeTab.scrollIntoView({
          behavior: 'smooth',
          block: 'nearest',
          inline: 'center'
        });
        
        // Method 2 (fallback): Calculate and set scroll position manually
        // This provides a backup in case scrollIntoView doesn't work as expected
        setTimeout(() => {
          const containerWidth = tabsContainer.offsetWidth;
          const tabWidth = activeTab.offsetWidth;
          const tabLeft = activeTab.offsetLeft;
          const scrollPosition = tabLeft - (containerWidth / 2) + (tabWidth / 2);
          
          tabsContainer.scrollTo({
            left: scrollPosition,
            behavior: 'smooth'
          });
        }, 50);
      }, 100);
    }
  }
  
  // Center active tab on page load
  centerActiveTab();
  
  // Center active tab on window resize
  window.addEventListener('resize', centerActiveTab);
  
  // Re-center when orientation changes (important for mobile)
  window.addEventListener('orientationchange', centerActiveTab);
  
  // Ensure centering works after page is fully loaded (including images)
  window.addEventListener('load', centerActiveTab);
});

Key improvements in this solution:

  • Adds multiple delays to ensure elements are fully rendered before attempting to center
  • Uses both scrollIntoView() and manual scroll position calculation as a fallback
  • Handles window resize and orientation change events
  • Adds an additional check on the load event (after all resources are loaded)

2. CSS Adjustments

Ensure the tabs container is properly set up for scrolling:

.tabs-container {
  display: flex;
  overflow-x: auto;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE and Edge */
  -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
  scroll-behavior: smooth;
  
  &::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
  }
}

/* Mobile styles */
@media (max-width: 768px) {
  .tabs-container {
    scroll-snap-type: x mandatory; /* Improves scroll positioning */
    
    .tab-item {
      scroll-snap-align: center; /* Helps with centering when scrolling */
    }
  }
}

3. HTML Structure Optimization

Ensure the HTML structure doesn't have nested scrollable containers that might interfere with the scrolling behavior:

<div class="tabs-wrapper">
  <div class="tabs-container" id="tabs-container">
    <!-- Tab items -->
  </div>
</div>

4. Additional Improvements

  1. Remove Unnecessary Event Propagation Stop

As noted in the PR comments, remove e.stopPropagation() in docs-table-of-contents.js:

link.click(function (e) {
    e.preventDefault();
    // e.stopPropagation(); - Remove this line
    var $parentContent = $(this).parent('.accordion-content');
    $parentContent.toggleClass("accordion-up");
    // Toggle visibility of H4 elements under this H3
    $parentContent.children('.sub-accordion-content').toggle();
});
  1. Add Accessibility Improvements

Enhance the tab navigation with proper ARIA attributes:

<div class="tabs-wrapper" role="navigation" aria-label="Main Navigation">
  <div class="tabs-container" id="tabs-container">
    <!-- For each tab -->
    <div class="tab-item">
      <a href="..." class="tab-link" role="tab" aria-selected="true">Tab Title</a>
    </div>
  </div>
</div>

Conclusion

The top navigation tabs implementation is a significant improvement to the Tyk documentation site's user experience. The most critical issue to address is the mobile tab visibility problem, where the active tab is not always visible on mobile devices.

The recommended solution provides multiple approaches to ensure the active tab is centered properly on mobile devices, with fallbacks and event handlers to handle various scenarios. By implementing these changes, the navigation experience on mobile devices should be significantly improved, ensuring that users can always see the active tab regardless of which section they're viewing.


Tip: Mention me again using /probe <request>.
Powered by Probe AI

@yurisasuke yurisasuke merged commit 2d8363a into master May 13, 2025
12 checks passed
@yurisasuke yurisasuke deleted the feature/old-tabs-to-docs branch May 13, 2025 14:54
@sharadregoti
Copy link
Contributor

/release to release-5.8

Copy link

tykbot bot commented May 13, 2025

Working on it! Note that it can take a few minutes.

tykbot bot pushed a commit that referenced this pull request May 13, 2025
* Implement top navigation tabs (#6354)

(cherry picked from commit 2d8363a)
Copy link

tykbot bot commented May 13, 2025

@sharadregoti Created merge PRs

buger added a commit that referenced this pull request May 13, 2025
Implement top navigation tabs (#6354) (#6394)

* Implement top navigation tabs (#6354)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants