Skip to content

fix: only hide primary tabs for users with toolbar access#623

Merged
jjroelofs merged 1 commit into7.xfrom
jur/6.x/609-fix-tabs-hidden-for-non-admin-users
Sep 30, 2025
Merged

fix: only hide primary tabs for users with toolbar access#623
jjroelofs merged 1 commit into7.xfrom
jur/6.x/609-fix-tabs-hidden-for-non-admin-users

Conversation

@jjroelofs
Copy link
Collaborator

Summary

Fixes a bug where primary tabs (local tasks) were hidden for all users when admin_toolbar_tools was configured to show local tasks, even for users who don't have permission to access the admin toolbar.

Changes

  • Added permission check in dxpr_theme_preprocess_menu_local_tasks()
  • Primary tabs are now only hidden for users with access toolbar permission
  • Users without toolbar permissions continue to see the primary tabs since they can't see them in the admin toolbar

Test plan

  • Test with user who has toolbar access - tabs should be hidden when admin_toolbar_tools is configured
  • Test with user without toolbar access - tabs should remain visible
  • Verify admin_toolbar_tools configuration still works correctly for admin users

Closes #609

🤖 Generated with Claude Code

Primary tabs were being hidden for all users when admin_toolbar_tools
was configured to show local tasks, even for users without toolbar
permissions who couldn't see the tasks in the admin toolbar.

Fixes #609

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@jjroelofs jjroelofs merged commit 88c4f77 into 7.x Sep 30, 2025
3 checks passed
@jjroelofs jjroelofs deleted the jur/6.x/609-fix-tabs-hidden-for-non-admin-users branch September 30, 2025 15:25
jjroelofs added a commit that referenced this pull request Oct 1, 2025
Primary tabs were being hidden for all users when admin_toolbar_tools
was configured to show local tasks, even for users without toolbar
permissions who couldn't see the tasks in the admin toolbar.

Fixes #609

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-authored-by: Jurriaan Roelofs <jur@dxpr.com>
Co-authored-by: Claude <noreply@anthropic.com>
jjroelofs added a commit that referenced this pull request Dec 18, 2025
* feat: update Google Webfonts database (#610)

Co-authored-by: jjroelofs <jjroelofs@users.noreply.github.com>

* fix: only hide primary tabs for users with toolbar access (#623)

Primary tabs were being hidden for all users when admin_toolbar_tools
was configured to show local tasks, even for users without toolbar
permissions who couldn't see the tasks in the admin toolbar.

Fixes #609

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-authored-by: Jurriaan Roelofs <jur@dxpr.com>
Co-authored-by: Claude <noreply@anthropic.com>

* fix: prevent tabs from being hidden below header on pages without title

Previously, tabs were positioned with translate(-50%, -100%) which caused them to be hidden below the header on pages without a page title. Changed to translate(-50%, 0) to fix this issue.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Revert "fix: prevent tabs from being hidden below header on pages without title"

This reverts commit 1bd28e2.

* fix: when toolbar local tasks enabled hide primary tabs but NOT secondary tabs

* fix: tiny pager/tabs text, fall back to bootstrap default file size

* fix: modernize mobile fixed header using Drupal displacement API

Use Drupal's displacement API CSS variables to properly position the
mobile fixed header and prevent content overlap.

Changes:
- Add `top: var(--drupal-displace-offset-top, 0px)` to position header
  below admin toolbar
- Change body padding to `calc(var(--dxt-setting-header-mobile-height) +
  var(--drupal-displace-offset-top, 0px))` to account for both header
  and toolbar
- Remove obsolete `#toolbar-bar.header-mobile-fixed` CSS rule
- Add z-index to mobile fixed header for proper stacking

This replaces the legacy JavaScript-based approach that was removed in
commit d9e8fde with a modern CSS-only solution that integrates with
Drupal core's displacement system.

Fixes #677

* fix: modernize desktop header using Drupal displacement API

Extend the displacement API modernization to desktop header positioning
and remove legacy toolbar-specific CSS overrides.

Changes:
- Use `var(--drupal-displace-offset-top)` for desktop fixed header `top`
- Use `calc(header-height + offset)` for desktop body padding
- Use `calc(offset + 30px)` for overlay header design spacing
- Remove 35 lines of toolbar-specific CSS overrides (39px, 80px, etc.)
- Remove legacy Drupal 7 admin_menu CSS (body.admin-menu)
- Keep Gin toolbar horizontal offset handling

The displacement API automatically handles all toolbar states:
- Standard toolbar (39px)
- Toolbar with tray open (80px)
- No toolbar (0px)

This reduces CSS complexity and ensures consistent behavior with any
admin toolbar configuration.

* fix: only apply mobile padding when header-mobile-fixed is enabled

Use CSS :has() selector to detect when mobile fixed header is actually
enabled (navbar has header-mobile-fixed class). Without this check,
padding was incorrectly applied even when mobile header was static,
creating a gap at the top of the page.

- Reset padding-top to 0 for mobile mode by default
- Only add padding when :has(#navbar.header-mobile-fixed) matches

* fix: remove hardcoded toolbar offsets, use displacement API

- Remove hardcoded 39px/80px toolbar offsets from header-theme-settings-css.inc
- Use Drupal's displacement API (--drupal-displace-offset-top) for header positioning
- Simplify desktop fixed header body padding to just header height
- Remove conflicting Gin toolbar body padding rule from SCSS
- Add !important to mobile padding reset to override Gin's rules

This modernizes the toolbar handling to work with any admin toolbar
configuration without hardcoded pixel values.

* fix: reset body padding for Gin vertical toolbar

Gin vertical toolbar sets --gin-toolbar-y-offset to 0px on desktop
because the toolbar is positioned on the side. Our dynamic theme
settings CSS was adding header height as body padding, creating a
visible gap at the top.

Add explicit reset rule for Gin vertical toolbar that sets body
padding-top to 0 with !important to override the dynamic CSS.

* chore: clean up code comments for production

Simplify verbose comments to be more concise while preserving
essential context.

* fix: apply Gin sidebar offset to sticky header (affix)

The sticky header (affix class) was setting left:0 which caused
the header to overlap the Gin sidebar when scrolling. Now both
the fixed and affix states respect the Gin toolbar offset.

* fix: improve mobile fixed header body padding logic

- Reset desktop padding only when mobile fixed header is NOT enabled
- Add body padding only when #navbar.header-mobile-fixed is present
- Handle Gin vertical toolbar padding separately
- Use !important to override conflicting styles

* fix: reset margin on fixed headers to prevent 1-2px offset

* fix: overlap Gin toolbar 1px border to eliminate visual gap

* fix: handle all Gin toolbar modes (vertical, horizontal, classic)

- Add 1px border overlap fix for gin--horizontal-toolbar and gin--classic-toolbar
- Navigation module uses --drupal-displace-offset-top so existing code handles it

* fix: add gin--core-navigation and gin--navigation-top-bar classes

* fix: add gin--navigation class to header positioning rules

Add support for gin--navigation body class in the Gin border overlap
fix. This ensures the 1px header offset is applied when using Gin with
the Navigation module.

* fix: use 6px offset for gin--navigation toolbar gap

The Drupal displacement API reports 60px for gin--navigation but the
actual toolbar is only 54px. Use -6px offset instead of -1px to
correctly align the fixed header with this toolbar configuration.

Keep -1px for other Gin toolbar modes (vertical, horizontal, classic,
core-navigation) where the 1px border causes the visual gap.

* fix: rename data-offset-top to prevent collision with Drupal displacement API

The Bootstrap affix plugin used data-offset-top attribute to configure
sticky header scroll offset. However, Drupal's displace.js also reads
any element with data-offset-top attribute to calculate displacement
offsets. This caused --drupal-displace-offset-top to be incorrectly
set to 60px (from theme settings) instead of the actual toolbar height.

Renamed to data-affix-offset-top to avoid the naming collision. DXPR
Theme's sticky header implementation uses drupalSettings values rather
than reading this data attribute, so no JS changes are needed.

* fix: position theme settings sidebar below admin toolbar

Use --drupal-displace-offset-top CSS variable to position the theme
settings sidebar below the admin toolbar. This ensures the search bar
and sidebar content align properly with the Gin toolbar height.

* fix: make Save configuration button sticky at bottom of settings sidebar

The save button is now always visible at the bottom of the theme
settings sidebar regardless of scroll position.

* fix: set --drupal-displace-offset-right for settings sidebar

The theme settings sidebar is 35vw wide and fixed on the right side.
Setting the displacement API variable allows other page elements to
respond to the sidebar's presence.

* fix: style save button with black background and white text

* Revert "merge: resolve conflicts from 6.x branch"

This reverts commit b251047, reversing
changes made to c712782.

* fix: resolve stylelint issues in SCSS files

- Use flex-flow shorthand instead of flex-direction + flex-wrap
- Remove units from zero values in CSS variable fallbacks
- Add empty line before comment per SCSS style guide

* fix: reword comment to avoid eslint spellcheck error

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: jjroelofs <jjroelofs@users.noreply.github.com>
Co-authored-by: Jurriaan Roelofs <jur@dxpr.com>
Co-authored-by: Claude <noreply@anthropic.com>
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.

Primary tabs hidden for users without toolbar permissions when admin_toolbar_tools is configured

1 participant