Skip to content

fix(table): removed first/last child padding, added inset#7050

Closed
mattnolting wants to merge 9 commits intopatternfly:mainfrom
mattnolting:fix-table-first-last-child
Closed

fix(table): removed first/last child padding, added inset#7050
mattnolting wants to merge 9 commits intopatternfly:mainfrom
mattnolting:fix-table-first-last-child

Conversation

@mattnolting
Copy link
Collaborator

@mattnolting mattnolting commented Sep 9, 2024

closes #7032
closes #11058

Updated Table Iso Backstop Report
Updated Full Backstop Report

Examples: https://patternfly-pr-7050.surge.sh/components/table

TLDR:

Floating :first/:last-child pseudos result in a huge number of selector matching attempts. Attaching these pseudos to a selector results in a massive reduction in matching attempts.

The cell padding and button fitting updates are the result of a somewhat hidden bug. thead row heights are affected erratically by using negative margining on table__button cells. See below:

Before

Screenshot 2024-09-17 at 10 56 47 AM Screenshot 2024-09-17 at 10 56 05 AM Screenshot 2024-09-17 at 10 53 34 AM Screenshot 2024-09-17 at 10 52 39 AM

After

Screenshot 2024-09-17 at 10 57 35 AM Screenshot 2024-09-17 at 10 57 23 AM Screenshot 2024-09-17 at 10 57 10 AM Screenshot 2024-09-17 at 10 56 58 AM

Table :first/:last-child css declarations are relics that should be standardized. As per a recent conversation w/ @lboehling, :first/:last-child th/td padding definitions can/should be simplified, while inset updates should be optional.

Also, toggles, checkboxes, radios, actions, etc do not need special spacing.

These need to be updated

Performance impact

This PR

  • Reduces match attempts by 4,361,984
  • Improves performance by 2%
  • Reduces blocking time by 50ms

Before

Screenshot 2024-09-10 at 11 57 31 AM

After

Screenshot 2024-09-10 at 11 49 02 AM

Before

Screenshot 2024-09-10 at 12 03 46 PM

After

Screenshot 2024-09-10 at 12 05 26 PM

Backstop report

@patternfly-build
Copy link
Collaborator

patternfly-build commented Sep 9, 2024

Copy link
Contributor

@mcoker mcoker left a comment

Choose a reason for hiding this comment

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

I'm seeing slightly different results in the backstop report - backstop-first-last-child-table.pdf.

At a glance, it looks like expandable toggles are no longer aligned with the row text? https://patternfly-pr-7050.surge.sh/components/table#expandable

cc @lboehling, would you mind looking at the report or table examples and see if this looks as you'd expect?

@mattnolting mattnolting force-pushed the fix-table-first-last-child branch 4 times, most recently from d7689aa to 8c8e486 Compare September 20, 2024 17:55
@mattnolting
Copy link
Collaborator Author

TLDR:

Line height has been standardized to create consistent row height. Currently, rows without actionable elements are shorter than rows with actionable elements. Table sort buttons are shorter than plain buttons (row toggles) which creates a presentational difference, especially notable when a thead toggle button is adjacent to a thead sort button. Because line-height is defined as 1.5, thead block height resolves to 18px, instead of 21px, which is the default for buttons or menu-toggles. It also results in vertical misalignment as some elements may that may not be as tall as others. In order to correct this, a standardized line-height of table--LineHeight * table--FontSize(not th/td LineHeight * th/td FontSize) has been applied to all cells. The result is a consistent block height that is independent of font-size.

@lboehling @kaylachumley @andrew-ronaldson Can you take a look at Backstop report?

What changed

Help

Screenshot 2024-09-20 at 3 46 46 PM

Screenshot 2024-09-20 at 3 47 43 PM

Checkboxes

Screenshot 2024-09-20 at 3 16 22 PM

Screenshot 2024-09-20 at 3 16 31 PM

Radio

Screenshot 2024-09-20 at 3 33 18 PM

Expandable

Screenshot 2024-09-20 at 3 17 46 PM

Screenshot 2024-09-20 at 3 17 35 PM

Compact

Screenshot 2024-09-20 at 3 30 26 PM

Screenshot 2024-09-20 at 3 30 32 PM

Compound expansion

Screenshot 2024-09-20 at 3 34 39 PM

Screenshot 2024-09-20 at 3 27 25 PM

Favorites

Screenshot 2024-09-20 at 3 28 42 PM

Compact

Screenshot 2024-09-20 at 3 30 26 PM

Screenshot 2024-09-20 at 3 30 32 PM

Borderless

Screenshot 2024-09-20 at 3 28 12 PM

Compound expansion

Tree table

Screenshot 2024-09-20 at 3 28 01 PM

Screenshot 2024-09-20 at 3 27 48 PM

  • Rather than negative margins on sort buttons, table__action cells have been standardized to exclude top padding (in thead cells) and bottom padding (in tbody cells). Margin top has been added to thead sort buttons and bottom margin has been added to tbody sort buttons to retain a common default height of 53px when standard th/td content is absent.

Screenshot 2024-09-20 at 3 39 15 PM

Screenshot 2024-09-20 at 3 39 20 PM

  • Specific padding variables __toggle, __check, __action , __draggable, __favorite have been abstracted to --#{$table}--cell--action--PaddingBlockStart/End: var(--pf-t--global--spacer--control--vertical--plain); and --#{$table}--cell--action--PaddingInlineStart/End: var(--pf-t--global--spacer--action--horizontal--plain--default);

Screenshot 2024-09-20 at 3 40 12 PM

Mobile presentation has been simplified and has changed slightly as a result

  • padding-block-start/end is consistent

Screenshot 2024-09-20 at 4 00 29 PM

Screenshot 2024-09-20 at 4 01 23 PM

Screenshot 2024-09-20 at 4 01 58 PM

Screenshot 2024-09-20 at 4 02 27 PM

Screenshot 2024-09-20 at 4 02 53 PM

@mattnolting mattnolting force-pushed the fix-table-first-last-child branch from 8c8e486 to c4eff46 Compare September 20, 2024 20:03
Copy link
Member

@srambach srambach left a comment

Choose a reason for hiding this comment

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

I haven't made it all the way through, but ran regression tests on the table examples. I'm seeing some shifts in all different directions and really can't discern what's correct.

I believe the line height change causes some to move up, some down. Spot checks on the desktop width show they are 21px with 16px top and bottom, so that's good.

Mobile view seems to show increased height; is that also intended? e.g. pf-core__components_table_html_sortable-example_0_document_0_mobile.png

Left-right shifts seem to be a difference in padding - I can't actually tell from the issue description - what's the desired padding?

A couple of other things I noticed:
/components/table/html/borderless-expandable-example has some expanded content that lost it's left padding

/components/table/html/borderless-with-compound-expansion-example the kebabs no longer align horizontally between the main table and expanded section

@mcoker
Copy link
Contributor

mcoker commented Sep 25, 2024

Backstop report PDF - https://drive.google.com/file/d/1KK0zfG0OJPquXKql5AhnLY8pKRWMJWL-/view?usp=sharing
Full report - https://drive.google.com/file/d/13jjqKLZjH9kVlSKXFDVRui9C7GLVRbQu/view?usp=sharing

  • You'll need to download, unzip, then open backstop_data -> html_report -> index.html

cc @srambach

@mattnolting mattnolting force-pushed the fix-table-first-last-child branch 2 times, most recently from b826b1b to 6dfc8ee Compare September 26, 2024 17:06
@mattnolting mattnolting force-pushed the fix-table-first-last-child branch 2 times, most recently from 153ebe8 to a648b9c Compare September 26, 2024 20:11
@mattnolting
Copy link
Collaborator Author

@mattnolting mattnolting force-pushed the fix-table-first-last-child branch from a648b9c to 31b29de Compare September 26, 2024 22:21
@mattnolting
Copy link
Collaborator Author

mattnolting commented Sep 27, 2024

Updated Table Iso Backstop Report
Updated Full Backstop Report

Comment on lines -133 to -136
--#{$table}--cell--PaddingBlockStart: var(--#{$table}--m-grid--cell--PaddingBlockStart);
--#{$table}--cell--PaddingInlineEnd: var(--#{$table}--m-grid--cell--PaddingInlineEnd);
--#{$table}--cell--PaddingBlockEnd: var(--#{$table}--m-grid--cell--PaddingBlockEnd);
--#{$table}--cell--PaddingInlineStart: var(--#{$table}--m-grid--cell--PaddingInlineStart);
Copy link
Collaborator Author

@mattnolting mattnolting Sep 27, 2024

Choose a reason for hiding this comment

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

  • --#{$table}--cell--PaddingBlockStart
  • --#{$table}--cell--PaddingInlineEnd
  • --#{$table}--cell--PaddingBlockEnd
  • --#{$table}--cell--PaddingInlineStart

These values are being assigned on lines 141-145 rather than variable chaining. Controlling the chained variables, especially when getting further into modifiers like m-compact, m-clickable, m-selectable, is overly complicated and very fragile. Standard assignment provides clarity, prevents unintended value inheritance, enhances readability, and avoids forced reflows.

  .#{$table}__th, .#{$table}__td {
    padding-block-start: var(--#{$table}--m-grid--cell--PaddingBlockStart);
    padding-block-end: var(--#{$table}--m-grid--cell--PaddingBlockEnd);
    padding-inline-start: var(--#{$table}--m-grid--cell--PaddingInlineStart);
    padding-inline-end: var(--#{$table}--m-grid--cell--PaddingInlineEnd);

--#{$table}-td--responsive--GridColumnGap: var(--pf-t--global--spacer--md);
--#{$table}--cell--responsive--PaddingBlockStart: var(--pf-t--global--spacer--md);
--#{$table}--cell--responsive--PaddingBlockEnd: var(--pf-t--global--spacer--sm);
--#{$table}--cell--first-child--responsive--PaddingBlockStart: var(--pf-t--global--spacer--sm);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

--#{$table}--cell--first-child--responsive--PaddingBlockStart is no longer necessary as padding is being redefined without targeting first/last children in the grid layout.

--#{$table}--m-compact__check--responsive--MarginBlockStart: #{pf-size-prem(7px)};
--#{$table}--m-compact__action--responsive--MarginBlockStart: calc(var(--pf-t--global--spacer--xs) * -1);
--#{$table}--m-compact__action--responsive--MarginBlockEnd: calc(var(--pf-t--global--spacer--xs) * -1);
--#{$table}--m-compact__check--responsive--MarginBlockStart: var(--pf-t--global--spacer--sm);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This can be removed as it's no longer used or necessary.

Comment on lines +117 to +118
--#{$table}--m-grid__check--MarginInlineStart: var(--#{$table}__tbody--responsive--border-width--base);
--#{$table}--m-grid__check--PaddingBlockStart: var(--pf-t--global--spacer--sm);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

All other variables including --#{$table}--responsive should be updated to --#{$table}--m-grid as they are each others equivalent, and using them interchangeably is confusing and adds complexity.

Comment on lines +82 to +85
// * Table caption selected
--#{$table}--m-grid__caption--PaddingInlineEnd: var(--pf-t--global--spacer--lg);
--#{$table}--m-grid__caption--PaddingInlineStart: var(--pf-t--global--spacer--lg);

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Table caption padding needs to match table cell padding. These variables do no exist currently and need to be applied with this update.

Comment on lines -102 to -105
--#{$table}--m-compact__tr__td--responsive--PaddingBlockEnd: var(--pf-t--global--spacer--xs);
--#{$table}--m-compact__check--responsive--MarginBlockStart: #{pf-size-prem(7px)};
--#{$table}--m-compact__action--responsive--MarginBlockStart: calc(var(--pf-t--global--spacer--xs) * -1);
--#{$table}--m-compact__action--responsive--MarginBlockEnd: calc(var(--pf-t--global--spacer--xs) * -1);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These variables are no longer necessary as they are now part of the standardized cell--actions.

Comment on lines +101 to +105
// * Table cell action
--#{$table}--cell--action--PaddingBlockStart: var(--pf-t--global--spacer--sm);
--#{$table}--cell--action--PaddingBlockEnd: var(--pf-t--global--spacer--sm);
--#{$table}--cell--action--PaddingInlineStart: var(--pf-t--global--spacer--sm);
--#{$table}--cell--action--PaddingInlineEnd: var(--pf-t--global--spacer--sm);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

--#{$table}__action has been abstracted to --#{$table}--cell--action and applied to all cells that contain interactive elements.

Comment on lines -727 to -731
--#{$table}--cell--PaddingBlockStart: var(--#{$table}__toggle--PaddingBlockStart);
--#{$table}--cell--PaddingBlockEnd: var(--#{$table}__toggle--PaddingBlockEnd);
--#{$table}--cell--PaddingInlineStart: var(--#{$table}__toggle--PaddingInlineStart);
--#{$table}--cell--PaddingInlineEnd: var(--#{$table}__toggle--PaddingInlineEnd);

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Toggle no longer needs a specific padding as it belongs to the .#{$table}--cell--action group.

Comment on lines -753 to -779
--#{$table}--cell--PaddingInlineStart: var(--#{$table}__check--PaddingInlineStart);
--#{$table}--cell--PaddingInlineEnd: var(--#{$table}__check--PaddingInlineEnd);

vertical-align: top;

.#{$check} {
--#{$check}__label--FontSize: var(--#{$table}--cell--FontSize);
--#{$check}__label--LineHeight: var(--#{$table}--cell--LineHeight);
}

.#{$check},
.#{$radio} {
--#{$radio}__label--FontSize: var(--#{$table}--cell--FontSize);
--#{$radio}__label--LineHeight: var(--#{$table}--cell--LineHeight);
}

thead & {
vertical-align: bottom;
}

.#{$check}.pf-m-standalone,
.#{$radio}.pf-m-standalone {
thead & {
display: table-cell;
height: auto;
line-height: 1;
vertical-align: baseline;
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Special styling for __check is no longer necessary as its height has been standardized to table-_FontSize * table__LineHeight or 21px resulting in vertical alignment with all other elements.

Comment on lines +800 to +803
.#{$table}__thead & {
padding-block-start: 0;
padding-block-end: var(--#{$table}--cell--action--PaddingBlockEnd);
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

For thead .#{$table}--cell--action cells, only bottom padding needs to be applied in order to create consistent vertical alignment, as thead is set to vertical-align: bottom.

Comment on lines +806 to +809
.#{$table}__tbody & {
padding-block-start: var(--#{$table}--cell--action--PaddingBlockStart);
padding-block-end: 0;
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

For tbody .#{$table}--cell--action cells, only bottom padding needs to be applied in order to create consistent vertical alignment, as tbody is set to vertical-align: top.

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.

Bug - Table - Applying info prop causes Th misalignment Table first/last child padding updates

5 participants