Skip to content

Commit

Permalink
fix(listitem): fix row actions issue
Browse files Browse the repository at this point in the history
  • Loading branch information
scottdickerson committed Nov 17, 2020
1 parent 23de823 commit 5664f66
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ const DataSeriesFormItem = ({
}}
/>
),
rowActions: [
rowActions: () => [
<Button
key={`data-item-${series.dataSourceId}`}
renderIcon={Edit16}
Expand Down
22 changes: 8 additions & 14 deletions src/components/List/ListItem/ListItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,11 @@ const ListItem = ({
</div>
) : null;

const hasRowActions =
rowActions && (typeof rowActions === 'function' || !isEmpty(rowActions));

const renderRowActions = () =>
rowActions &&
(typeof rowActions === 'function' || rowActions.length > 0) ? (
hasRowActions ? (
<div className={`${iotPrefix}--list-item--content--row-actions`}>
{typeof rowActions === 'function' ? rowActions() : rowActions}
</div>
Expand Down Expand Up @@ -244,9 +246,7 @@ const ListItem = ({
{
[`${iotPrefix}--list-item--category`]: isCategory,
[`${iotPrefix}--list-item--content--values__disabled`]: disabled,
[`${iotPrefix}--list-item--content--values--value__with-actions`]: !isEmpty(
rowActions
),
[`${iotPrefix}--list-item--content--values--value__with-actions`]: hasRowActions,
}
)}
title={value}>
Expand All @@ -262,9 +262,7 @@ const ListItem = ({
`${iotPrefix}--list-item--content--values--value`,
`${iotPrefix}--list-item--content--values--value__large`,
{
[`${iotPrefix}--list-item--content--values--value__with-actions`]: !isEmpty(
rowActions
),
[`${iotPrefix}--list-item--content--values--value__with-actions`]: hasRowActions,
[`${iotPrefix}--list-item--content--values__disabled`]: disabled,
}
)}>
Expand All @@ -281,9 +279,7 @@ const ListItem = ({
{
[`${iotPrefix}--list-item--category`]: isCategory,
[`${iotPrefix}--list-item--content--values__disabled`]: disabled,
[`${iotPrefix}--list-item--content--values--value__with-actions`]: !isEmpty(
rowActions
),
[`${iotPrefix}--list-item--content--values--value__with-actions`]: hasRowActions,
}
)}
title={value}>
Expand All @@ -295,9 +291,7 @@ const ListItem = ({
className={classnames(
`${iotPrefix}--list-item--content--values--value`,
{
[`${iotPrefix}--list-item--content--values--value__with-actions`]: !isEmpty(
rowActions
),
[`${iotPrefix}--list-item--content--values--value__with-actions`]: hasRowActions,
[`${iotPrefix}--list-item--content--values__disabled`]: disabled,
}
)}>
Expand Down
5 changes: 4 additions & 1 deletion src/components/List/ListItem/ListItem.story.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,10 @@ export const WithOverflowMenuRowActions = () => (
<ListItem
{...dndProps}
id="list-item"
value={text('value', 'List Item')}
value={text(
'value',
'List Item with really long values does it ellipse when I get really long text'
)}
isExpandable={boolean('isExpandable', true)}
onExpand={action('onExpand')}
rowActions={[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,9 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT Exper
>
<div
className="iot--list-item--content--values--value iot--list-item--content--values--value__with-actions"
title="List Item"
title="List Item with really long values does it ellipse when I get really long text"
>
List Item
List Item with really long values does it ellipse when I get really long text
</div>
<div
className="iot--list-item--content--row-actions"
Expand Down
2 changes: 1 addition & 1 deletion src/components/List/ListItem/_list-item.scss
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@
text-overflow: ellipsis;
padding-right: $spacing-09;
&__with-actions {
padding-right: 0;
padding-right: $spacing-06; // save room for the action button
width: $spacing-05;
}
&__large {
Expand Down

0 comments on commit 5664f66

Please sign in to comment.