Skip to content

fix(card): remove padding/margin on clickable cards action element#7928

Merged
mcoker merged 3 commits into
patternfly:mainfrom
wise-king-sullyman:fix-padding-on-actionable-only-card
Oct 27, 2025
Merged

fix(card): remove padding/margin on clickable cards action element#7928
mcoker merged 3 commits into
patternfly:mainfrom
wise-king-sullyman:fix-padding-on-actionable-only-card

Conversation

@wise-king-sullyman

Copy link
Copy Markdown
Collaborator

Closes #7899

@patternfly-build

patternfly-build commented Oct 23, 2025

Copy link
Copy Markdown
Collaborator

@mcoker mcoker requested a review from srambach October 24, 2025 00:16

@thatblindgeye thatblindgeye left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, just thinking that wwe probably want to make an update for when a selectable input is also hidden, like in the React card as tiles examples. @mcoker

&:has(button, a) {
padding: 0;
margin: 0;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If I'm reading the issue correctly, this should be scoped just to the pf-m-clickable card. As is, this is removing padding and margin for any card actions that contain a link or button - which is probably all or most of them, right?

@mcoker

mcoker commented Oct 24, 2025

Copy link
Copy Markdown
Contributor

we probably want to make an update for when a selectable input is also hidden, like in the React card as tiles examples.

Yep, any time the actions element is in the DOM but invisible, it shouldn't impact the layout of the card.

@mcoker mcoker left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM! Just one little nit so it would work better with nested cards.

Comment on lines +200 to +201
&.pf-m-clickable:not(.pf-m-selectable),
&:has(input.#{$pf-prefix}u-screen-reader) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You'd probably want a more narrow scope on the input to be able to handle nested cards. > .#{$card}__selectable-actions is optional but I'd include it because who knows if someone has some other thing in their card actions that could trigger this style change.

Suggested change
&.pf-m-clickable:not(.pf-m-selectable),
&:has(input.#{$pf-prefix}u-screen-reader) {
&.pf-m-clickable:not(.pf-m-selectable),
&:has(> .#{$card}__header > .#{$card}__actions > .#{$card}__selectable-actions input.#{$pf-prefix}u-screen-reader) {

It's probably more efficient to write it this way though (not tested) since targeting the input only needs to start at the __actions container?

Suggested change
&.pf-m-clickable:not(.pf-m-selectable),
&:has(input.#{$pf-prefix}u-screen-reader) {
@at-root .#{$card}__actions:has(> .#{$card}__selectable-actions input.#{$pf-prefix}u-screen-reader),
&.pf-m-clickable:not(.pf-m-selectable) {

@mcoker

mcoker commented Oct 27, 2025

Copy link
Copy Markdown
Contributor

@srambach @wise-king-sullyman I pushed the update from my comment about updating the scope in this commit fbe2de1

Also it removes the u- from input.#{$pf-prefix}u-screen-reader and uses input.#{$pf-prefix}screen-reader since the react component uses pf-v6-screen-reader, not the utility class.

To verify that it works with tiles, I copied/pasted the HTML from the react cards as tiles example into the core preview with these changes.

@srambach srambach left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Visual regressions on card looked good. Just one suggestion to add a comment if you like.

// stylelint-enable selector-max-class

// when the whole card is clickable and the card actions are invisible, remove the padding/margin so it doesn't take up space
@at-root .#{$card}__actions:has(> .#{$card}__selectable-actions input.#{$pf-prefix}screen-reader),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

My only comment would be maybe it's worth a comment here to explain what this selector is aiming to do since it's pretty obscure and really only in react.

@mcoker mcoker merged commit bbf455e into patternfly:main Oct 27, 2025
4 checks passed
@mcoker

mcoker commented Oct 27, 2025

Copy link
Copy Markdown
Contributor

@srambach thanks for running visual regressions!!

@patternfly-build

Copy link
Copy Markdown
Collaborator

🎉 This PR is included in version 6.5.0-prerelease.7 🎉

The release is available on:

Your semantic-release bot 📦🚀

edonehoo pushed a commit to edonehoo/patternfly that referenced this pull request Nov 11, 2025
…atternfly#7928)

* fix(card): remove padding/margin on clickable cards action element

* fix(card): only remove padding on actionable only or hidden input cards

* chore: update selector

---------

Co-authored-by: mcoker <mcoker@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug - clickable card actions take up space when invisible

5 participants