Skip to content

feat(Table): add hasAction flag #11877

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/react-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"tslib": "^2.8.1"
},
"devDependencies": {
"@patternfly/patternfly": "6.3.0-prerelease.33",
"@patternfly/patternfly": "6.3.0-prerelease.36",
"case-anything": "^3.1.2",
"css": "^3.0.0",
"fs-extra": "^11.3.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/react-docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"test:a11y": "patternfly-a11y --config patternfly-a11y.config"
},
"dependencies": {
"@patternfly/patternfly": "6.3.0-prerelease.33",
"@patternfly/patternfly": "6.3.0-prerelease.36",
"@patternfly/react-charts": "workspace:^",
"@patternfly/react-code-editor": "workspace:^",
"@patternfly/react-core": "workspace:^",
Expand Down
2 changes: 1 addition & 1 deletion packages/react-icons/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"@fortawesome/free-brands-svg-icons": "^5.15.4",
"@fortawesome/free-regular-svg-icons": "^5.15.4",
"@fortawesome/free-solid-svg-icons": "^5.15.4",
"@patternfly/patternfly": "6.3.0-prerelease.33",
"@patternfly/patternfly": "6.3.0-prerelease.36",
"fs-extra": "^11.3.0",
"tslib": "^2.8.1"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/react-styles/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"clean": "rimraf dist css"
},
"devDependencies": {
"@patternfly/patternfly": "6.3.0-prerelease.33",
"@patternfly/patternfly": "6.3.0-prerelease.36",
"change-case": "^5.4.4",
"fs-extra": "^11.3.0"
},
Expand Down
4 changes: 4 additions & 0 deletions packages/react-table/src/components/Table/Td.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ export interface TdProps extends BaseCellProps, Omit<React.HTMLProps<HTMLTableDa
select?: TdSelectType;
/** Turns the cell into an actions cell. Recommended to use an ActionsColumn component as a child of the Td rather than this prop. */
actions?: TdActionsType;
/** Indicates the cell contains an interactive element and prevents that element's padding from increasing row height. Recommended when other cells in the same row contains text. */
hasAction?: boolean;
/** Turns the cell into an expansion toggle and determines if the corresponding expansion row is open */
expand?: TdExpandType;
/** Turns the cell into a compound expansion toggle */
Expand Down Expand Up @@ -84,6 +86,7 @@ const TdBase: React.FunctionComponent<TdProps> = ({
children,
className,
isActionCell = false,
hasAction = false,
component = 'td',
dataLabel,
textCenter = false,
Expand Down Expand Up @@ -279,6 +282,7 @@ const TdBase: React.FunctionComponent<TdProps> = ({
styles.tableTd,
className,
isActionCell && styles.tableAction,
hasAction && styles.modifiers.action,
textCenter && styles.modifiers.center,
noPadding && styles.modifiers.noPadding,
isStickyColumn && scrollStyles.tableStickyCell,
Expand Down
2 changes: 2 additions & 0 deletions packages/react-table/src/components/Table/examples/Table.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ To make a cell an action cell, render an `ActionsColumn` component inside a row'

If actions menus are getting clipped by other items on the page, such as sticky columns or rows, the `ActionsColumn` can be passed a `menuAppendTo` prop to adjust where the actions menu is appended.

When a table row contains mixed content of text and interactive elements, the `hasAction` property may be passed to a `Td` which contains interactive content like the below example's start `Button`. This will align buttons and other elements with other cells' text. Note that `hasAction` should not be used with `Td`s in an `ActionsColumn` because that comes with it's own spacing.

```ts file="TableActions.tsx"

```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export const TableActions: React.FunctionComponent = () => {
<Td dataLabel={columnNames.prs}>{repo.prs}</Td>
<Td dataLabel={columnNames.workspaces}>{repo.workspaces}</Td>
<Td dataLabel={columnNames.lastCommit}>{repo.lastCommit}</Td>
<Td dataLabel={columnNames.singleAction} modifier="fitContent">
<Td dataLabel={columnNames.singleAction} modifier="fitContent" hasAction>
{singleActionButton}
</Td>
<Td isActionCell>
Expand Down
2 changes: 1 addition & 1 deletion packages/react-tokens/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
},
"devDependencies": {
"@adobe/css-tools": "^4.4.2",
"@patternfly/patternfly": "6.3.0-prerelease.33",
"@patternfly/patternfly": "6.3.0-prerelease.36",
"fs-extra": "^11.3.0"
}
}
18 changes: 9 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3639,10 +3639,10 @@ __metadata:
languageName: node
linkType: hard

"@patternfly/patternfly@npm:6.3.0-prerelease.33":
version: 6.3.0-prerelease.33
resolution: "@patternfly/patternfly@npm:6.3.0-prerelease.33"
checksum: 10c0/36fc724fdfd810e8cb36cfeddf6534469305039f6514dab71b477447de8b408757ffa9d4273702e327f9c0cf7e4fd40c9e92c8ffc9ddd98e013e2ba2d356b0ee
"@patternfly/patternfly@npm:6.3.0-prerelease.36":
version: 6.3.0-prerelease.36
resolution: "@patternfly/patternfly@npm:6.3.0-prerelease.36"
checksum: 10c0/1c50ce51475581efe7c88885153a6ef1e69ffab8e7b016073d684294aa173b05081da8f313609e81f3eeea456874726934295e2837349ff109ed90eb15e9ad9a
languageName: node
linkType: hard

Expand Down Expand Up @@ -3740,7 +3740,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@patternfly/react-core@workspace:packages/react-core"
dependencies:
"@patternfly/patternfly": "npm:6.3.0-prerelease.33"
"@patternfly/patternfly": "npm:6.3.0-prerelease.36"
"@patternfly/react-icons": "workspace:^"
"@patternfly/react-styles": "workspace:^"
"@patternfly/react-tokens": "workspace:^"
Expand All @@ -3761,7 +3761,7 @@ __metadata:
resolution: "@patternfly/react-docs@workspace:packages/react-docs"
dependencies:
"@patternfly/documentation-framework": "npm:^6.5.20"
"@patternfly/patternfly": "npm:6.3.0-prerelease.33"
"@patternfly/patternfly": "npm:6.3.0-prerelease.36"
"@patternfly/patternfly-a11y": "npm:5.1.0"
"@patternfly/react-charts": "workspace:^"
"@patternfly/react-code-editor": "workspace:^"
Expand Down Expand Up @@ -3801,7 +3801,7 @@ __metadata:
"@fortawesome/free-brands-svg-icons": "npm:^5.15.4"
"@fortawesome/free-regular-svg-icons": "npm:^5.15.4"
"@fortawesome/free-solid-svg-icons": "npm:^5.15.4"
"@patternfly/patternfly": "npm:6.3.0-prerelease.33"
"@patternfly/patternfly": "npm:6.3.0-prerelease.36"
fs-extra: "npm:^11.3.0"
tslib: "npm:^2.8.1"
peerDependencies:
Expand Down Expand Up @@ -3885,7 +3885,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@patternfly/react-styles@workspace:packages/react-styles"
dependencies:
"@patternfly/patternfly": "npm:6.3.0-prerelease.33"
"@patternfly/patternfly": "npm:6.3.0-prerelease.36"
change-case: "npm:^5.4.4"
fs-extra: "npm:^11.3.0"
languageName: unknown
Expand Down Expand Up @@ -3927,7 +3927,7 @@ __metadata:
resolution: "@patternfly/react-tokens@workspace:packages/react-tokens"
dependencies:
"@adobe/css-tools": "npm:^4.4.2"
"@patternfly/patternfly": "npm:6.3.0-prerelease.33"
"@patternfly/patternfly": "npm:6.3.0-prerelease.36"
fs-extra: "npm:^11.3.0"
languageName: unknown
linkType: soft
Expand Down
Loading