Skip to content

Stick header on view open using _sth height param - #615

Open
CSWinnall wants to merge 1 commit into
devfrom
fix/stick-header-on-open-hsv
Open

Stick header on view open using _sth height param#615
CSWinnall wants to merge 1 commit into
devfrom
fix/stick-header-on-open-hsv

Conversation

@CSWinnall

Copy link
Copy Markdown
Collaborator

When a view with hide/show (_hsv) opens, read the height parameter from its _sth keyword and pass it to ktl.views.stickTableHeader so the sticky header uses the configured height. Add JSDoc for hideShowView to document the hide/show behavior and restoration of dependent features.

@CSWinnall
CSWinnall requested a review from cortexrd July 20, 2026 14:19

@cortexrd cortexrd left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

The height fix is correct — params[0][1] matches the canonical parser in stickyTableHeader(), and it fixes the previously-invalid height: undefinedpx CSS. One change requested before merge:

Add the numOfRecords gate. The normal render path skips sticky when the table is small (if (data.length < numOfRecords) return; — default 10). This path has no such gate, and since the height was previously invalid CSS, small tables were unaffected in practice. With this PR, a 3-row table inside an _hsv view will get a real 800px-tall wrapper of mostly empty space when expanded. Suggest:

const stickyHeaderParams = keywords._sth?.[0]?.params?.[0] || [];
const numOfRecords = stickyHeaderParams[0] || 10;
const viewHeight = stickyHeaderParams[1] || 800;
const rowCount = Knack.views[viewId]?.model?.data?.length || 0;
if (rowCount >= numOfRecords)
    ktl.views.stickTableHeader(viewId, viewHeight);

Minor (optional): since keywords._sth is now read directly, the ktl.core.checkIfViewHasKeyword(viewId, '_sth') call is redundant — if (keywords._sth) would do, keeping one source of truth.

@CSWinnall

CSWinnall commented Jul 27, 2026 via email

Copy link
Copy Markdown
Collaborator Author

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