Gin Compatibility: Account for "open" vertical toolbar

Created on 25 January 2023, almost 2 years ago
Updated 9 August 2023, over 1 year ago

When using the default Gin toolbar settingβ€”"Sidebar, Vertical Toolbar"β€”the toolbar can be either open, showing the icons and text labels for each menu item, or closed, showing only the icons. The toolbar can be opened or closed according to the user's preference using the open/close button. I believe the default initial state is open.

Gin Vertical Toolbar WITHOUT Environment Indicator

If Environment Indicator is not enabled, when a user hovers one of the main items of an open toolbar, that item's sub-menu appears offset to the right by an amount that accounts for the width of the open toolbar, leaving the icons and text labels fully visible and available to hover or click as illustrated below:

(EDIT: The behavior described above was introduced in Gin 3.0-rc1. In previous versions, sub-menus did overlay the main toolbar item text labels.)

Gin Vertical Toolbar WITH Environment Indicator

When Environment Indicator is enabled, sub-menu positioning only accounts for a closed toolbar, so when a user hovers the main toolbar items for an open toolbar, the sub-menu appears positioned too far to the left, and covers the main item text labels. See below:

In addition to diverging from the default Gin behavior, this is amounts to a UI regression in that:

  1. Users who choose the open toolbar likely need/want the additional context provided by the text labels, so we shouldn't cover them, and
  2. A user who is attempting to click a main toolbar item text label will find that the label is immediately covered, and they could inadvertently click the sub-menu item that appears in it's place.

Proposed Solution

Emulate Gin's sub-menu CSS with positioning that accounts for both closed and open toolbar states.

πŸ› Bug report
Status

Closed: outdated

Version

4.0

Component

User interface

Created by

πŸ‡ΊπŸ‡ΈUnited States justcaldwell Austin, Texas

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @justcaldwell
  • Assigned to justcaldwell
  • πŸ‡ΊπŸ‡ΈUnited States justcaldwell Austin, Texas

    Working on a patch.

  • @justcaldwell opened merge request.
  • πŸ‡ΊπŸ‡ΈUnited States justcaldwell Austin, Texas

    MR15 replaces --gin-toolbar-width-collapsed with --gin-toolbar-x-offset and removes -4px/-3px margin adjustments which seem no longer necessary.

    Gin actually uses --gin-toolbar-x-offset to position sub-menus. It is calculated using --gin-toolbar-width (for open toolbar) and --gin-toolbar-width-collapsed (for closed toolbar), and it also takes the screen width into account.

    This change also (mostly) fixed another issue I noticed. Before the change, sub-menus had excessive margin/indentation with Environment Indicator enabled at screen widths < 976px β€” basically the "tablet" breakpoint (below, left). The extra margin was replaced, though, with a small negative margin that caused sub-menus to slightly overlap the border (below, middle). To resolve that, I removed the "-4px" margin adjustment that was previously introduced by #3309626: Integration with Gin Toolbar and Admin Toolbar β†’ (below, right).

    This worked well at all screen widths, at least with Gin 3.0-rc1. So much so, that I also removed the (seemingly redundant?) -3px margin adjustment that was being added to <li>s by environment_indicator.js.

    I still plan to test with Gin 3.0-beta5, but it seems like the margin adjustments are no longer needed. I can only assume something in Gin changed that addressed the extra margin described in #3309626: Integration with Gin Toolbar and Admin Toolbar β†’ .

    I'm hoping someone else on Gin 3.0-rc1 can test these changes.

  • Status changed to Needs review almost 2 years ago
  • πŸ‡ΊπŸ‡ΈUnited States justcaldwell Austin, Texas
  • πŸ‡ΊπŸ‡ΈUnited States justcaldwell Austin, Texas

    After testing with Gin 3.0-beta5, here's what I've learned:

    The extra margin described in #3309626: Integration with Gin Toolbar and Admin Toolbar β†’ still appears in beta5, but is no longer an issue in Gin 3.0-rc1. So, Environment Indicator no longer needs to include the negative margin adjustment for sites on Gin 3.0-rc1+. We can still support earlier versions with a fallback value:

    /* TODO: Remove this when it's no longer necessary to support Gin 3.0@beta. */
    @media (min-width: 61em) {
      [dir="ltr"] .gin--vertical-toolbar .toolbar-menu-administration > .toolbar-menu > .menu-item .toolbar-menu {
        margin-left: var(--gin-toolbar-x-offset, calc(var(--ginVerticalToolbarOffset) - 7px));
      }
    
      [dir="rtl"] .gin--vertical-toolbar .toolbar-menu-administration > .toolbar-menu > .menu-item .toolbar-menu {
        margin-right: var(--gin-toolbar-x-offset, calc(var(--ginVerticalToolbarOffset) - 7px));
      }
    }

    This consolidates the previous negative margin adjustments (-7px in total) in CSS, rather than having -4px in CSS, and -3px in JS. The media query prevents the margin issues at smaller breakpoints described in #4.

    The margin adjustment is only applied to the fallback value (--ginVerticalToolbarOffset for beta5 and earlier), since RC1's --gin-toolbar-x-offset doesn't need it. In fact, when we use --gin-toolbar-x-offset, we're doing exactly what Gin is doing (as of RC1), so this block becomes redundant once it's no longer necessary to support older versions, and it can be removed entirely (per the TODO comment).

  • Issue was unassigned.
  • πŸ‡ΊπŸ‡ΈUnited States justcaldwell Austin, Texas
  • Status changed to Closed: outdated over 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States devkinetic

    There is a more recent issue #3367093-8: Gin compatibility: Small screen vertical toolbar submenu items margin too big β†’ where the css has been removed along with the js to support the latest versions of Gin, which is currently at 3.0.0-rc5.

Production build 0.71.5 2024