Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Sep 20, 2025

Problem

The sidebar hamburger menu button was inaccessible on Identity pages (e.g., /Identity/Account/Login, /Identity/Account/Register) due to JavaScript errors that prevented the Vue.js application from initializing properly.

Root Cause

On Identity pages, the TOC_DATA global variable and other ViewBag-dependent variables are null because these pages don't have table of contents data. The JavaScript code was attempting to iterate over these null values without proper null checks, causing runtime errors:

// This would fail when TOC_DATA is null on Identity pages
const tocData = markRaw(TOC_DATA);
const currentPage = findCurrentPage([], tocData) ?? [];

function findCurrentPage(path, items) {
    for (const item of items) { // TypeError: items is null
        // ...
    }
}

Solution

Implemented defensive programming practices throughout the JavaScript code:

  1. Safe initialization: markRaw(TOC_DATA || []) provides empty array fallback
  2. Null checks before iteration: Added guards in findCurrentPage() function
  3. Safe computed properties: Added null checks in filteredTocData
  4. Protected forEach usage: Added null check before tocData.forEach()
  5. Fixed layout inheritance: Corrected Manage layout to use existing main layout

Result

  • ✅ Sidebar button now works on all Identity pages
  • ✅ Keyboard shortcut (Ctrl+M) functions correctly everywhere
  • ✅ No JavaScript errors in browser console
  • ✅ Existing functionality on content pages unchanged
  • ✅ Graceful degradation when TOC data is unavailable

The changes are minimal and surgical, focusing only on null safety without altering the core sidebar functionality or user experience.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • api.hcaptcha.com
    • Triggering command: /usr/share/dotnet/dotnet exec --runtimeconfig /home/REDACTED/work/EssentialCSharp.Web/EssentialCSharp.Web/EssentialCSharp.Web.Tests/bin/Debug/net9.0/EssentialCSharp.Web.Tests.runtimeconfig.json --depsfile /home/REDACTED/work/EssentialCSharp.Web/EssentialCSharp.Web/EssentialCSharp.Web.Tests/bin/Debug/net9.0/EssentialCSharp.Web.Tests.deps.json /home/REDACTED/work/EssentialCSharp.Web/EssentialCSharp.Web/EssentialCSharp.Web.Tests/bin/Debug/net9.0/testhost.dll --port 34247 --endpoint 127.0.0.1:034247 --role client --parentprocessid 6139 --telemetryoptedin false (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@Copilot Copilot AI changed the title [WIP] Sidebar <button class="menu-btn has-tooltip"><i class="fa fa-bars fa-lg icon-light"></i><span class="tooltip-text sidebar-tooltip-text"><b>Ctrl + M</b></span></button> Is inaccessbile on identity pages (ex: https://essentialcsharp.com/Identity... Fix sidebar accessibility on Identity pages by handling null TOC_DATA Sep 20, 2025
Copilot finished work on behalf of BenjaminMichaelis September 20, 2025 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants