[UI] Fix Resources dropdown requiring double click on Cloud and Kanvas pages#1032
Conversation
Signed-off-by: AsparkArcane <nathan.dsouza.610@gmail.com>
There was a problem hiding this comment.
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.
|
Sbragul26
left a comment
There was a problem hiding this comment.
@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>
|
I clicked signed off and commit changes |
|
Hi @Sbragul26 |
| otherDropdown.classList.remove("current"); | ||
| otherDropdown.nextElementSibling.classList.remove("show"); | ||
| otherDropdown.nextElementSibling.style.visibility = "hidden"; | ||
| const menu = otherDropdown.nextElementSibling; |
There was a problem hiding this comment.
In lines 232 to 236, please correct the indentation for consistency
Signed-off-by: Nathan Dsouza <nathan.dsouza.610@gmail.com>
|
@Sbragul26 thanks for the review! |
|
Thank you for contributing to the Layer5 community! 🎉 \ \ |

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