Skip to content

Fix banner overlay caused by !important padding-top in host app#35

Merged
saturnflyer merged 1 commit intomainfrom
banner-js-optimization
Feb 10, 2026
Merged

Fix banner overlay caused by !important padding-top in host app#35
saturnflyer merged 1 commit intomainfrom
banner-js-optimization

Conversation

@saturnflyer
Copy link
Member

@saturnflyer saturnflyer commented Feb 10, 2026

Summary

  • When the gem is added to an app with !important on body { padding-top }, the banner padding was overridden, causing the banner to overlay page content instead of pushing it down
  • Banner JS now detects !important rules from other stylesheets and mirrors that priority on the newshound rule via CSSOM setProperty
  • Padding is managed through the stylesheet rule (with an id on the style element) instead of inline styles, eliminating the conflict between the two approaches
  • Rule reference and priority detection are cached to avoid redundant DOM/CSSOM queries on resize and toggle

Test plan

  • Add gem to an app that has !important on body padding-top and verify the banner pushes content down
  • Verify banner toggle (expand/collapse) correctly updates padding
  • Verify window resize correctly updates padding
  • Verify apps without !important padding rules still work correctly

When the newshound gem was added to an application that had an !important
rule on body padding-top, the banner padding was overridden, causing the
banner to overlay page content instead of pushing it down.

The banner JS now detects !important rules on body padding-top from other
stylesheets and mirrors that priority on the newshound rule. Padding is
managed via the CSSOM (setProperty) on the existing stylesheet rule
instead of inline styles, so both approaches no longer conflict. The
style element has an ID for direct access, and the rule reference and
priority detection are cached to avoid redundant queries on resize and
toggle.

Fixed: Banner overlaying content in apps with !important body padding-top rules
@saturnflyer saturnflyer requested a review from a team as a code owner February 10, 2026 20:31
@saturnflyer saturnflyer merged commit 91af61a into main Feb 10, 2026
4 checks passed
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.

1 participant