Skip to content

Fix sticky footer for pages with short content#382

Merged
JakeSCahill merged 7 commits into
mainfrom
fix/sticky-footer
May 27, 2026
Merged

Fix sticky footer for pages with short content#382
JakeSCahill merged 7 commits into
mainfrom
fix/sticky-footer

Conversation

@JakeSCahill
Copy link
Copy Markdown
Contributor

@JakeSCahill JakeSCahill commented May 27, 2026

Summary

Fix the footer jumping/floating issue caused by the back-to-top button affecting document flow.

Problem

On pages with minimal content, the footer would "jump" when scrolling past 300px because the back-to-top button used position: static with margin-top: 150px. When JavaScript toggled it from display: none to display: flex, it added ~175px to the document flow.

Solution

Changed .back-to-top to use position: fixed so showing/hiding the button doesn't affect layout:

  • Position fixed at bottom center of viewport
  • Added background, shadow, and z-index for visibility
  • Button floats over content instead of being part of document flow

Files Changed

File Change
src/css/doc.css Make back-to-top button position fixed
src/css/main.css Simplified min-height calculation
src/css/footer.css Add flex-shrink: 0 to prevent footer shrinking

Preview Links

Test the fix on these pages:

Page Link
Sticky Footer Test (short content) https://deploy-preview-382--docs-ui.netlify.app/sticky-footer-test
Bloblang Syntax (long content) https://deploy-preview-382--docs-ui.netlify.app/bloblang-syntax-test
Home Page https://deploy-preview-382--docs-ui.netlify.app/home
Playground https://deploy-preview-382--docs-ui.netlify.app/playground

Test Plan

  • Scroll down past 300px on any page - footer should NOT jump
  • Back-to-top button appears as fixed overlay at bottom center
  • Footer stays at bottom of viewport on short content pages
  • Long pages still have proper content/footer spacing

When page content is shorter than the viewport, the footer was floating
in the middle of the page instead of staying at the bottom.

Fix by:
- Add flex: 1 0 auto to .content so it grows to fill available space
- Add margin-top: auto to footer as a fallback

Also add:
- Sticky footer test page to verify the fix
- Dev Tools nav section with Widget Test and Sticky Footer Test pages
@netlify
Copy link
Copy Markdown

netlify Bot commented May 27, 2026

Deploy Preview for docs-ui ready!

Name Link
🔨 Latest commit 2b584f4
🔍 Latest deploy log https://app.netlify.com/projects/docs-ui/deploys/6a16eea123e2ad0008ebdf83
😎 Deploy Preview https://deploy-preview-382--docs-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 32 (🟢 up 2 from production)
Accessibility: 89 (no change from production)
Best Practices: 83 (🔴 down 17 from production)
SEO: 89 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 27, 2026

Review Change Stack

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5c07c479-0415-41d9-8c20-4e0bed0d9daf

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR implements a sticky footer layout pattern. The core changes replace the previous min-height and layout containment approach in the footer and main content area with flexbox-based rules: footer.footer gains margin-top: auto to push the footer to the bottom, main > .content gains flex: 1 0 auto to allow content to grow, and the containment rule is removed. A new test page documents the expected behavior and is registered in the navigation model under a new Dev Tools section.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive The PR description mentions changes to src/css/doc.css and src/css/footer.css with specific modifications (position fixed for back-to-top, flex-shrink), but the actual changeset shows no modifications to src/css/doc.css and different footer changes (margin-top: auto instead of flex-shrink), creating a mismatch between stated and actual changes. Update the PR description to accurately reflect all actual file changes, including removal of contain properties from main.css and clarification of footer modifications.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title directly and clearly describes the main change: fixing the sticky footer layout for pages with short content, which is the core objective of this pull request.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/sticky-footer

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

The contain: layout and contain: layout style properties were causing
layout recalculations during scroll, making the footer appear to jump.

Also removed unnecessary min-height: 300px from footer which was
reserving excessive space.
The docs pages use .docs-footer class, not footer.footer.
Changed margin-top from fixed 64px to auto so footer pushes
to bottom when content is short.
The back-to-top button was using static positioning with margin-top: 150px.
When JavaScript toggled it from display:none to display:flex at scrollY > 300,
it added ~175px to the document flow, causing the footer to jump down.

Changed to position: fixed at bottom of viewport so showing/hiding the button
doesn't affect layout.
@JakeSCahill JakeSCahill requested a review from a team May 27, 2026 12:27
Repositioned from center (left: 50%) to bottom-right (right: 24px, bottom: 100px)
to avoid overlapping the contribution links in the feedback section.
Copy link
Copy Markdown
Contributor

@micheleRP micheleRP left a comment

Choose a reason for hiding this comment

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

Review

Approving — idiomatic flexbox sticky-footer pattern, clean implementation, deploy preview is green.

Worth verifying before merge

  1. CLS impactfooter.footer loses min-height: 300px and contain: layout style, both of which had comments calling them out as "Reserve space to prevent CLS" / "Isolate rendering". The new sticky-footer flow may compensate naturally, but it's worth a Lighthouse / CLS spot-check on the deploy preview before merging.
  2. .back-to-top placementposition: fixed; bottom: 100px; right: 24px. On short pages the footer sits at the viewport bottom, so the button may visually overlap or sit very close to the footer. On long pages, 100px from the bottom puts it mid-screen rather than near the edge. A quick visual sanity check across page lengths would be reassuring.

Coordination

  1. preview-src/ui-model.yml — this PR adds a "Dev Tools" parent + sticky footer test link. PR #381 also adds a "Dev Tools" parent + a different test link. Whichever lands second will need a merge-conflict resolution that combines both entries.

What works well

  • Idiomatic flex: 1 0 auto + margin-top: auto pattern.
  • Replaces the hacky margin-top: 150px on back-to-top with proper fixed positioning.
  • New sticky-footer-test.adoc preview page gives a regression test surface.
  • All checks green.

- Restore min-height: 200px on footer.footer to reserve space and reduce CLS
- Move back-to-top from bottom: 100px to bottom: 24px to sit at viewport edge

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@JakeSCahill JakeSCahill merged commit b2fda81 into main May 27, 2026
6 checks passed
@JakeSCahill JakeSCahill deleted the fix/sticky-footer branch May 27, 2026 13:22
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.

2 participants