Skip to content

fix(card): let the shortcode's padding argument express zero - #2152

Merged
markdumay merged 1 commit into
mainfrom
fix/card-padding-zero
Sep 3, 2026
Merged

fix(card): let the shortcode's padding argument express zero#2152
markdumay merged 1 commit into
mainfrom
fix/card-padding-zero

Conversation

@markdumay

Copy link
Copy Markdown
Collaborator

Problem

padding is an integer whose 0 is a real value — "no padding" — but the card shortcode resolved it through two layers that each read falsy as absent:

{{- $padding := partial "utilities/GetArgParent" (dict "page" . "arg" "padding") | default 3 -}}

GetArgParent takes the argument under with, which skips 0 and returns the empty string. The trailing | default 3 then skips it again. An author writing padding=0 got 3, and nothing was logged.

It stayed invisible while the argument's only job was the card body's own p-N, where the difference reads as a styling choice rather than an ignored instruction. It stopped being invisible in #2150, which made padding the control for the horizontal card's button spacing: padding=0 is now how you ask for a button with no gap above it, and it was the one value the argument could not carry.

Found on a client site — the same card that motivated #2150 sets padding=0 and still rendered pt-3.

Change

InitArgs already tells an explicit 0 apart from an unset argument and applies the structure's default: 3, so own-value-or-default now comes from $args.padding. Only the parent cascade is applied by hand, and only when the card sets nothing itself — which keeps a group's padding reaching its cards while letting a card's explicit 0 win over it, the same trap one level up.

This also starts paying off the TODO: use initargs instead of GetArgParent sitting at the top of that argument block.

Tests

Five resolutions pinned in tests/templates, driven through a fixture page because the bug lives in the shortcode's own argument handling and a direct partial call bypasses it:

case want
explicit zero pt-0
explicit five pt-5
absent → structure default pt-3
inherits the group's padding pt-5
explicit zero beats the group pt-0

Against the unfixed shortcode, exactly the two zero cases fail and the build exits non-zero; the other three already passed, which is what scopes this to zero rather than to cascade or defaults generally. five is there so a card that ignored the argument entirely could not pass by coincidence with the default.

The cascade cases need the group a nested card reads its parent from, so card-group and pagination are mounted alongside. Locally: 84 PASS / 0 FAIL, exampleSite builds, all three linters clean.

Scope note

The falsy-is-absent behaviour in utilities/GetArgParent (mod-utils) is not fixed here. It affects any cascading argument whose meaningful value is falsy — an explicit false on a boolean whose default is truthy has the same problem — but changing it would alter argument resolution for every shortcode that calls the helper. That deserves its own change with its own blast-radius review rather than riding along with this one.

`padding` is an integer whose 0 is a real value - "no padding" - but the
shortcode resolved it through two layers that each read falsy as absent.
`utilities/GetArgParent` takes the argument under `with`, which skips 0 and
returns the empty string, and the shortcode then applied `| default 3`, which
skips it again. An author writing `padding=0` got 3, with nothing logged.

It stayed invisible while the argument's only job was the card body's own
`p-N`, where the difference reads as a styling choice. It stopped being
invisible when the horizontal card's button spacing began reading the same
argument: `padding=0` is now the way to ask for a button with no gap above it,
and it was the one value the argument could not carry.

InitArgs already tells an explicit 0 apart from an unset argument and applies
the structure's default, so own-value-or-default now comes from `$args`. Only
the parent cascade is applied by hand, and only when the card sets nothing
itself - which keeps a group's padding reaching its cards while letting a card's
explicit 0 win over it, the same trap one level up.

The five resolutions are pinned in tests/templates: zero, a non-default, absent,
inherited from the group, and zero overriding the group. Before the change two
of them fail - the two that pass a zero - and the build exits non-zero.

Scope note: the falsy-is-absent behaviour in GetArgParent is not fixed here. It
affects any cascading argument whose meaningful value is falsy, but changing it
would alter argument resolution for every shortcode that uses the helper, so it
wants its own change rather than riding along with this one.
@netlify

netlify Bot commented Sep 3, 2026

Copy link
Copy Markdown

Deploy Preview for gethinode-demo ready!

Name Link
🔨 Latest commit 3daa110
🔍 Latest deploy log https://app.netlify.com/projects/gethinode-demo/deploys/6a9920788e7ce0000829f883
😎 Deploy Preview https://deploy-preview-2152--gethinode-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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

@markdumay
markdumay merged commit 152fc78 into main Sep 3, 2026
17 checks passed
@markdumay
markdumay deleted the fix/card-padding-zero branch September 3, 2026 09:24
@markdumay

Copy link
Copy Markdown
Collaborator Author

🎉 This PR is included in version 3.23.9 🎉

The release is available on GitHub release

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.

1 participant