Skip to content

feat(header): Chevron right for collapsed - chevron down for expanded#4318

Open
Simpler1 wants to merge 1 commit intoZoneMinder:masterfrom
Simpler1:chevron_right_down
Open

feat(header): Chevron right for collapsed - chevron down for expanded#4318
Simpler1 wants to merge 1 commit intoZoneMinder:masterfrom
Simpler1:chevron_right_down

Conversation

@Simpler1
Copy link
Copy Markdown
Contributor

Simple change to make the chevrons easier to understand when the main-header-nav is collapsed or expanded.

The right chevron indicates collapsed.
The down chevron indicates expanded.

(Reference: https://stackoverflow.com/questions/18325779/bootstrap-3-collapse-show-state-with-chevron-icon)

@connortechnology
Copy link
Copy Markdown
Member

@IgorA100 opinion on this?

@IgorA100
Copy link
Copy Markdown
Contributor

IgorA100 commented Jul 2, 2025

opinion on this?

To be honest, after this PR it becomes even more unclear :)
Perhaps it really is worth thinking about changing the icons, but I don't really like the option with "keyboard_arrow_right".
Perhaps I'm too picky.

As an option - maybe replace with collapse_all + expand_all
In general, the entire top horizontal menu needs to be redesigned. Make it more convenient for narrow screens and mobile devices.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the classic skin header toggle affordance so the chevron direction reflects the collapsed/expanded state of the secondary navbar (“navbar-two”), and persists that state via a cookie.

Changes:

  • Switched the toggle icon behavior to use right chevron for collapsed and down chevron for expanded.
  • Renamed persisted cookie values from up/down to shown/hidden.
  • Updated PHP rendering logic to hide/show #navbar-two and set the initial chevron based on the cookie.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
web/skins/classic/js/skin.js Changes the toggle logic to swap keyboard_arrow_right/keyboard_arrow_down and writes `zmHeaderFlip=hidden
web/skins/classic/includes/functions.php Updates initial navbar visibility and the rendered chevron based on the new cookie values.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +892 to 893
$header = ( isset($_COOKIE['zmHeaderFlip']) and $_COOKIE['zmHeaderFlip'] == 'shown') ? 'down' : 'right';
$result .= '<li id="getHeaderFlipHTML" class="nav-item dropdown"><a class="nav-link" href="#"><i id="flip" class="material-icons md-18" style="display: inline-block;">keyboard_arrow_' .$header. '</i></a></li>'.PHP_EOL;
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

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

getHeaderFlipHTML() defaults the chevron to right unless the cookie is explicitly 'shown'. With no cookie set (first visit) the navbar is rendered visible, but the icon will indicate the collapsed state. Consider defaulting to down when the navbar is visible (e.g., when cookie is not 'hidden'), and also mapping legacy values (up/down) appropriately.

Copilot uses AI. Check for mistakes.
Comment on lines 301 to +309
function navbarTwoFlip() {
$j("#navbar-two").slideToggle("slow");
const flip = $j("#flip");
if ( flip.html() == 'keyboard_arrow_up' ) {
flip.html('keyboard_arrow_down');
setCookie('zmHeaderFlip', 'down');
if ( flip.html() == 'keyboard_arrow_down' ) {
flip.html('keyboard_arrow_right');
setCookie('zmHeaderFlip', 'hidden');
} else {
flip.html('keyboard_arrow_up');
setCookie('zmHeaderFlip', 'up');
flip.html('keyboard_arrow_down');
setCookie('zmHeaderFlip', 'shown');
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

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

navbarTwoFlip() decides which icon/cookie to set based on the current icon text (flip.html()). If a user arrives with no zmHeaderFlip cookie (or legacy values like up/down), the server-rendered icon/state can be out of sync with the actual #navbar-two visibility, causing the toggle to persist the wrong cookie value and display the wrong chevron. Consider basing the logic on #navbar-two's actual visibility (before toggling) and/or treating legacy cookie values (down => hidden, up/unset => shown) as aliases when computing the next state.

Copilot uses AI. Check for mistakes.

<nav class="navbar navbar-expand-md justify-content-center" id="navbar-two"
<?php echo ( isset($_COOKIE['zmHeaderFlip']) and $_COOKIE['zmHeaderFlip'] == 'down' ) ? 'style="display:none;"' : '' ?>
<?php echo ( isset($_COOKIE['zmHeaderFlip']) and $_COOKIE['zmHeaderFlip'] == 'hidden' ) ? 'style="display:none;"' : '' ?>
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

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

The new cookie value check only hides #navbar-two when zmHeaderFlip == 'hidden'. Users with an existing cookie from previous versions (down was used to indicate the hidden state) will now get the navbar shown unexpectedly and can end up with icon/state mismatches. Consider treating legacy values (e.g., down) as equivalent to hidden, or migrating/clearing the cookie.

Suggested change
<?php echo ( isset($_COOKIE['zmHeaderFlip']) and $_COOKIE['zmHeaderFlip'] == 'hidden' ) ? 'style="display:none;"' : '' ?>
<?php echo ( isset($_COOKIE['zmHeaderFlip']) && ( $_COOKIE['zmHeaderFlip'] == 'hidden' || $_COOKIE['zmHeaderFlip'] == 'down' ) ) ? 'style="display:none;"' : '' ?>

Copilot uses AI. Check for mistakes.
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.

4 participants