Skip to content

[UI] Fix Resources dropdown requiring double click on Cloud and Kanvas pages#1032

Open
AsparkArcane wants to merge 3 commits into
layer5io:masterfrom
AsparkArcane:resource-dropdown-fix
Open

[UI] Fix Resources dropdown requiring double click on Cloud and Kanvas pages#1032
AsparkArcane wants to merge 3 commits into
layer5io:masterfrom
AsparkArcane:resource-dropdown-fix

Conversation

@AsparkArcane
Copy link
Copy Markdown
Contributor

Notes for Reviewers

This PR fixes #1026

The Issue:
The setupDropdown function was querying for all elements with the .current class to close any open menus. On the Cloud/Kanvas pages, the active page link also carries the .current class but does not have a sibling dropdown menu. This caused otherDropdown.nextElementSibling to return null, throwing a TypeError when the script tried to access .classList. This error halted JavaScript execution during the first click, preventing the Resources menu from toggling.

The Fix:

  • Updated the selector in setupDropdown to querySelectorAll(".nav-link.current[data-toggle='dropdown']"). This ensures the script only attempts to close actual dropdown menus and ignores active page indicators.

  • Added a null check (if (otherDropdown.nextElementSibling)) as a safety measure to prevent future script crashes if the DOM structure varies.

  • This fix ensures consistent single-click behavior across the Home, Cloud, and Kanvas pages.

Signed commits

  • Yes, I signed my commits.

Signed-off-by: AsparkArcane <nathan.dsouza.610@gmail.com>
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refines the navbar dropdown logic by narrowing the selection criteria to elements with the data-toggle='dropdown' attribute and adding a safety check for the sibling element. Feedback suggests refactoring the safety check to store the sibling element in a variable to improve readability and performance, while also recommending similar robustness checks for other dropdown-related variables.

Comment thread layouts/partials/navbar.html Outdated
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 12, 2026

🚀 Preview deployment: https://layer5io.github.io/docs/pr-preview/pr-1032/

Note: Preview may take a moment (GitHub Pages deployment in progress). Please wait and refresh. Track deployment here

Copy link
Copy Markdown
Member

@Sbragul26 Sbragul26 left a comment

Choose a reason for hiding this comment

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

@AsparkArcane , please address the Gemini bot review suggestions as well.

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Signed-off-by: Nathan Dsouza <nathan.dsouza.610@gmail.com>
@AsparkArcane
Copy link
Copy Markdown
Contributor Author

I clicked signed off and commit changes

@AsparkArcane
Copy link
Copy Markdown
Contributor Author

Hi @Sbragul26
Are there any changes left to be made?

Comment thread layouts/partials/navbar.html Outdated
otherDropdown.classList.remove("current");
otherDropdown.nextElementSibling.classList.remove("show");
otherDropdown.nextElementSibling.style.visibility = "hidden";
const menu = otherDropdown.nextElementSibling;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In lines 232 to 236, please correct the indentation for consistency

Signed-off-by: Nathan Dsouza <nathan.dsouza.610@gmail.com>
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.

[Docs] Resources dropdown should open in one click on all pages

2 participants