Skip to content

Advanced Header Off Canvas Trigger styles overridden by style-blocks-header.css due to stylesheet enqueue order #979

Description

@garethmidwood

Description

The Off Canvas Trigger block inside an Advanced Header has color and background-color settings that apply correctly in the block editor preview but are ignored on the frontend. Inline <style> rules generated by Kadence Blocks for the trigger are output in the page <head>, but the plugin's static stylesheet style-blocks-header.css is enqueued after them. Because both rule sets have equal specificity, the static stylesheet wins by cascade order and the user's settings are silently overridden.

Steps to reproduce

  1. Install Kadence Theme + Kadence Blocks 3.6.7 on a clean WordPress install
  2. Go to Kadence → Headers and create a new Advanced Header
  3. Add an Off Canvas Trigger block to the header
  4. In the block's sidebar, set Trigger Colors → Normal to a non-default value (e.g. #ffffff)
  5. Optionally set a non-default background color
  6. Publish the header
  7. Enable it via Appearance → Customize → Header → Use Block Header and select the new header
  8. View any page on the frontend (with all caching/minification disabled to rule out interference)

Expected behaviour

The trigger icon color and background-color match the values set in the block sidebar.

Actual behaviour

The trigger renders in the default color (black) and the background-color setting is ignored entirely. The block editor preview shows the correct colors, confirming the settings save and serialize fine.

Root cause (per browser inspection)

Viewing page source on the frontend:

  1. The inline <style> block containing the user's per-block rules is printed near the top of <head>.
  2. wp-content/plugins/kadence-blocks/dist/style-blocks-header.css?ver=3.6.7 is enqueued and loaded after the inline styles.
  3. The static stylesheet contains rules targeting the same trigger elements with equal CSS specificity.
  4. Per the CSS cascade, equal-specificity rules declared later win — so the static defaults override the user's settings.

The per-block customizations cannot beat the plugin's own defaults without !important or a higher-specificity selector being introduced somewhere.

Suggested fix

Any one of the following would resolve it:

  • Enqueue style-blocks-header.css early enough (e.g. via a higher priority on the wp_enqueue_scripts hook) that it loads before per-block inline styles.
  • Output the per-block inline CSS via wp_add_inline_style() attached to the kadence-blocks-header handle so WordPress automatically places it after the stylesheet.
  • Increase specificity of the inline rules — e.g. prefix selectors with the block's unique wrapper class — so they beat the static defaults regardless of source order.

The second option is probably the cleanest since it's the standard WordPress pattern for this exact problem.

Workaround

Adding equivalent rules to Appearance → Customize → Additional CSS works because Customizer CSS is output later than any plugin stylesheet. This isn't an acceptable long-term solution because it requires every Kadence user to manually re-implement settings the UI claims to control.

Environment

  • Kadence Blocks: 3.6.7
  • Kadence Theme: 1.4.5
  • WordPress: 6.9.4
  • PHP: 8.4.19
  • Browser tested: Chrome 147.0.7727.138
  • Tested with caching/minification disabled: yes — issue persists on a request to a fresh URL with no caching layer (also reproduces with WP-Optimize Minify both enabled and disabled, confirming the minifier is not the cause)

Notes

The rules in style-blocks-header.css could be observed loading after the inline overrides on a live staging site (URL available on request if helpful for the maintainer team).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions