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

Fix: Home Link in Navbar Not Navigating to Home Page on About Page. #968

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion about.html
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@
<a href="#" class="logo">Resum Resume<span>.</span></a>

<nav class="navbar">
<a href="#home">Home</a>
<a href="index.html">Home</a>
<a href="about.html">About</a>
<a href="resume.html">Build Resume</a>
<!-- <a href="signup.html">Sign Up</a> -->
Expand Down
26 changes: 17 additions & 9 deletions login.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,23 @@
<!-- Navbar section -->
<header>
<a href="index.html"><h1>Resum Resume<span>.</span></h1></a>
<nav>
<ul id="nav-menu">
<li><a href="#home">Home</a></li>
<li><a href="#about.html">About Us</a></li>
<li><a href="#resume.html">Resume</a></li>
<li><a href="#signup.html">Sign Up</a></li>
<li><a href="login.html">Login</a></li>
</ul>
</nav>
<nav>
<ul id="nav-menu">
<li><a href="index.html">Home</a></li>
<li><a href="about.html">About Us</a></li>
<li><a href="resume.html">Resume</a></li>
<li><a href="signup.html">Sign Up</a></li>
<li id="login-link"><a href="login.html">Login</a></li>
</ul>
</nav>
Comment on lines +19 to +27
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Enhance navigation accessibility and user experience.

While the navigation structure is semantically correct, consider these improvements:

  1. Add ARIA landmarks for better accessibility
  2. Indicate the current page in the navigation menu
-    <nav> 
+    <nav aria-label="Main navigation"> 
       <ul id="nav-menu">
-          <li><a href="index.html">Home</a></li>
-          <li><a href="about.html">About Us</a></li>
-          <li><a href="resume.html">Resume</a></li>
-          <li><a href="signup.html">Sign Up</a></li>
-          <li id="login-link"><a href="login.html">Login</a></li>
+          <li><a href="index.html" aria-label="Home page">Home</a></li>
+          <li><a href="about.html" aria-label="About us page">About Us</a></li>
+          <li><a href="resume.html" aria-label="Resume builder">Resume</a></li>
+          <li><a href="signup.html" aria-label="Sign up page">Sign Up</a></li>
+          <li id="login-link"><a href="login.html" aria-current="page" aria-label="Login page">Login</a></li>
       </ul>
   </nav>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<nav>
<ul id="nav-menu">
<li><a href="index.html">Home</a></li>
<li><a href="about.html">About Us</a></li>
<li><a href="resume.html">Resume</a></li>
<li><a href="signup.html">Sign Up</a></li>
<li id="login-link"><a href="login.html">Login</a></li>
</ul>
</nav>
<nav aria-label="Main navigation">
<ul id="nav-menu">
<li><a href="index.html" aria-label="Home page">Home</a></li>
<li><a href="about.html" aria-label="About us page">About Us</a></li>
<li><a href="resume.html" aria-label="Resume builder">Resume</a></li>
<li><a href="signup.html" aria-label="Sign up page">Sign Up</a></li>
<li id="login-link"><a href="login.html" aria-current="page" aria-label="Login page">Login</a></li>
</ul>
</nav>


<script>
// Hide the "Login" link if the user is on the login page
if (window.location.pathname.endsWith("login.html")) {
document.getElementById("login-link").style.display = "none";
}
</script>
Comment on lines +29 to +34
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Move inline script to external file and improve path handling.

The current implementation has several potential improvements:

  1. Inline scripts should be moved to external files
  2. Path checking could be more robust

Move this code to login.js and enhance it:

// In login.js
document.addEventListener('DOMContentLoaded', function() {
    const loginLink = document.getElementById('login-link');
    if (loginLink) {
        // More robust check using pathname or URL
        const currentPath = window.location.pathname;
        const isLoginPage = currentPath.toLowerCase().includes('login.html');
        if (isLoginPage) {
            loginLink.style.display = 'none';
        }
    }
});

Then remove the inline script from login.html:

-  <script>
-      // Hide the "Login" link if the user is on the login page
-      if (window.location.pathname.endsWith("login.html")) {
-          document.getElementById("login-link").style.display = "none";
-      }
-  </script>


<div class="nav-controls">
<a href="about.html" class="fas fa-info-circle"></a>
<a href="login.html" id="loginIcon" class="fas fa-user"></a>
Expand Down