fix(card): let the shortcode's padding argument express zero - #2152
Merged
Conversation
`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.
✅ Deploy Preview for gethinode-demo ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Collaborator
Author
|
🎉 This PR is included in version 3.23.9 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
paddingis an integer whose0is 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 -}}GetArgParenttakes the argument underwith, which skips0and returns the empty string. The trailing| default 3then skips it again. An author writingpadding=0got3, 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 madepaddingthe control for the horizontal card's button spacing:padding=0is 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=0and still renderedpt-3.Change
InitArgsalready tells an explicit0apart from an unset argument and applies the structure'sdefault: 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'spaddingreaching its cards while letting a card's explicit0win over it, the same trap one level up.This also starts paying off the
TODO: use initargs instead of GetArgParentsitting 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:pt-0pt-5pt-3pt-5pt-0Against 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.
fiveis 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-groupandpaginationare 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 explicitfalseon 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.