Skip to content

feat(core): add auto pagination to fit rows to container height#339

Merged
hjalmers merged 3 commits into
mainfrom
claude/auto-pagination-container-height-fYVPw
Jun 5, 2026
Merged

feat(core): add auto pagination to fit rows to container height#339
hjalmers merged 3 commits into
mainfrom
claude/auto-pagination-container-height-fYVPw

Conversation

@hjalmers

@hjalmers hjalmers commented Jun 5, 2026

Copy link
Copy Markdown
Owner

Summary

Adds support for automatic pagination that dynamically adjusts the number of visible rows based on the available container height. This allows tables to fill their parent container while maintaining a consistent row height, with pagination controls adapting as the container is resized.

Key Changes

  • Core library (projects/core/)

    • Extended TableConfig.pagination.length to accept 'auto' in addition to numeric values
    • Added autoPageSize signal to track the measured page size for auto-pagination mode
    • Implemented ResizeObserver-based measurement in _setupAutoPagination() to detect container/table size changes
    • Added _measureAutoPageSize() to calculate how many rows fit based on available height, row height, and header/footer heights
    • Added afterRenderEffect hook to re-measure after data/config changes (e.g., async data loads)
    • Updated processedData computed signal to use measured page size when length: 'auto'
    • Added isAutoPagination computed signal to track auto mode state
    • Set DEFAULT_AUTO_ROWS = 10 as fallback before measurement completes
    • Updated SCSS to make angular-generic-table a block element (required for height constraints)
    • Updated TableConfig JSDoc to document the new 'auto' option
  • Docs app (projects/docs/)

    • Created new AutoPaginationComponent example demonstrating the feature
    • Added resizable container with ResizeObserver sync to height control
    • Integrated form controls for height adjustment and search
    • Added route /auto-pagination to app routing
    • Updated navigation menu to include the new example
  • Tests (projects/core/)

    • Added test for default page size fallback before measurement
    • Added test for re-chunking data when measured page size changes

Implementation Details

  • Uses ResizeObserver to monitor both the host element and table element for size changes
  • Measurement is skipped in SSR/jsdom environments where element heights are unavailable (graceful degradation)
  • The feature requires the table to be placed inside a height-constrained container (e.g., height: 420px or max-height: 100%)
  • Measurement occurs after render to ensure DOM is fully laid out
  • Falls back to DEFAULT_AUTO_ROWS (10) until measurement completes, ensuring pagination works immediately
  • Compatible with existing search and sort functionality

https://claude.ai/code/session_01DgAfyT6dwHcsR9wztyHJM8

claude added 3 commits June 5, 2026 07:03
Widen `pagination.length` to `number | 'auto'`. When set to 'auto' the
table measures its (height-constrained) host container, subtracts the
header and footer heights, and divides by the row height to display as
many rows as fit. A ResizeObserver and an afterRenderEffect keep the page
size in sync with container resizes and async data loads; measurement
no-ops safely on SSR/jsdom or unconstrained containers, falling back to a
default page size.

Adds an "Auto pagination" docs example demonstrating a fixed-height flex
wrapper with a live height control.
The _source.ts snippet files consumed by the docs examples are
gitignored and generated by scripts/generate-sources.mjs. That script
only ran via prebuild:docs, so a fresh clone running `npm start` failed
with "Could not resolve './_source'". Add a prestart hook so the files
are generated before the dev server starts.
Add p-3 padding to the auto-pagination demo wrapper and make it
resizable like a text area (resize: vertical). A ResizeObserver syncs
drag-resizes back into the height control so both interactions stay in
step and the auto page size recalculates.
@hjalmers hjalmers merged commit b2f3194 into main Jun 5, 2026
2 checks passed
@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 5.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants