Skip to content

feat(common): add sticky headers to autoHeight grids - #1351

Open
ghiscoding wants to merge 2 commits into
masterfrom
feat/auto-height-sticky
Open

ghiscoding wants to merge 2 commits into
masterfrom
feat/auto-height-sticky

Conversation

@ghiscoding

Copy link
Copy Markdown
Collaborator

Summary

Add autoHeight: { stickyHeader: true } to keep the top-header panel, pre-header, column headers, and header row visible while an auto-height grid is scrolled.

This implements the feature requested in Discussion #994, adapted from slickgrid-universal PR #2934.

Why

An auto-height grid grows to show all its rows, so the page scrolls instead of the grid. On long grids, the column titles and filters otherwise scroll out of view.

Changes

  • Allow autoHeight to accept a boolean or an AutoHeightOption object. The object form enables auto-height, and stickyHeader: true enables sticky header layers. Existing boolean configurations retain their behavior.
  • Measure the top-header and header heights and expose them as CSS variables so the layers stack correctly.
  • Use CSS position: sticky without scroll listeners. The content root uses overflow: clip so the header row can stick to the scrolling ancestor.
  • Add optional CSS variables:
    • --slick-sticky-header-top offsets the headers below fixed page content; it defaults to 0px.
    • --slick-sticky-header-z-index controls their stacking order; it defaults to 7.
  • Update the auto-height example to demonstrate the header layers and a top offset.
  • Document the option and add unit and Cypress coverage.

Validation

  • npm run build: passed.
  • vitest run --config vitest.config.mts src/__tests__/slickGrid.spec.ts: 411 tests passed.
  • Example 11 Cypress: 2 tests passed, including header stacking, visibility, and disabling sticky headers at runtime. The run used the locally installed Cypress 16.2.1 binary with the project's 16.3.0 package.

Comments

Code that reads gridOptions.autoHeight as a boolean may need a truthy check such as !!gridOptions.autoHeight, because the option can now also be an object.

Sticky positioning uses the nearest ancestor with a scrolling mechanism. An ancestor with overflow: auto or hidden can prevent headers from sticking to the page if it is not the element being scrolled.

AI / LLM assistance

  • AI / LLM assistance used:
    • No
    • Yes
  • If Yes:
    • which tool/model: GitHub Copilot Claude Opus 5.5 for the fork implementation; OpenAI Codex (GPT-6 Terra) for the SlickGrid adaptation.
    • how was it used: Assisted with implementation, tests, the example, documentation, and validation.

Checklist

  • The changes are limited to only one scope.
  • Tests were added or updated where appropriate.
  • Documentation was updated where appropriate.

@codecov

codecov Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.42%. Comparing base (2d92685) to head (9e7f230).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1351   +/-   ##
=======================================
  Coverage   93.41%   93.42%           
=======================================
  Files          34       34           
  Lines       13524    13537   +13     
  Branches     4093     4098    +5     
=======================================
+ Hits        12634    12647   +13     
  Misses        686      686           
  Partials      204      204           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ghiscoding

ghiscoding commented Nov 14, 2026 •

Copy link
Copy Markdown
Collaborator Author

@6pac can you ask @6pac-ai for a review and per usual fix directly any issues it may find. This resolve a request made by a user (see above).

Side note, apart from the Pivot table PR (which I provided my feedback), I don't have anything in the queue. I think we'll be done for a while.

@ghiscoding ghiscoding changed the title feat(common): add sticky headers to autoHeight grids feat(common): add sticky headers to autoHeight grids Nov 14, 2026
- Give the sticky header root an opaque background so rows no longer
  show through an empty pre-header, and use the theme's header colour
  (#f8f8f8) as the fallback for the top-header panel.
- Link the auto-height example by its full URL, as docs/examples.md
  does, so the docs link check passes.
- Move the sticky header docs under Sticky docking, after the page
  introduction.
- Add the missing final newline to autoHeightOption.interface.ts.

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

@6pac-ai 6pac-ai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good, approving. The approach is sound: overflow: clip on the content root, unlike hidden, doesn't create a scroll container, so the header row can stick without any scroll listeners. I pushed one follow-up commit, 9e7f230:

  • Rows showing through the pre-header. When the pre-header panel has no columns, as in example 11, it is transparent, so rows that scroll under it showed through. The sticky header root now has an opaque --slick-header-bg-color background. The top-header panel's fallback colour now matches the theme default (#f8f8f8 instead of #ececec).
  • Docs link. /examples/example11-autoheight.html failed npm run links (missing page). I switched it to the full URL, the same form docs/examples.md uses.
  • Docs placement. The section sat above the page intro and the v6 tip, so I moved it under Sticky docking.
  • Newline. Added the missing final newline to autoHeightOption.interface.ts.

Verification

  • Vitest: 1574/1574 pass. The build, tsc --noEmit and lint are clean.
  • Cypress: example 11 passes. The 6 pinning specs passed on 603680b, 46/46 tests.
  • In the browser (example 11):
    • The layers stack correctly while the page scrolls: top header at 20px, then the header, then the header row.
    • Headers and filters stay aligned with the cells when the grid is scrolled horizontally.
    • setHeaderRowVisibility(), setPreHeaderPanelVisibility() and setTopHeaderPanelVisibility() update the CSS variables.
    • setOptions() switches sticky mode on and off.
    • With pinning.columns.left set, cells and headers are in the same positions with sticky on and off.

Note for consumers: widening the type to boolean | AutoHeightOption means TypeScript code that assigns options.autoHeight to a boolean will no longer compile. The PR description and the JSDoc already mention this.

This branch has not been deployed

No deployments
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