Skip to content
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

update visual snapshots: fix: do not render expand button when html field is empty #1682

Closed
wants to merge 4 commits into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,30 @@ export const HTMLCell: Cell = {
},
render: ({ content, component }) => {
return (
<scale-button
variant="secondary"
size="small"
icon-only
inner-aria-label={`Activate to ${
content.isExpanded ? 'collapse' : 'expand'
} content`}
onClick={() => {
content.isExpanded = !content.isExpanded;
component.forceRender++;
}}
>
{content.isExpanded ? (
<scale-icon-navigation-collapse-up
size={14}
></scale-icon-navigation-collapse-up>
) : (
<scale-icon-navigation-collapse-down
size={14}
></scale-icon-navigation-collapse-down>
)}
</scale-button>
content && (
<scale-button
variant="secondary"
size="small"
icon-only
aria-label={`Activate to ${
content.isExpanded ? 'collapse' : 'expand'
} content`}
onClick={() => {
content.isExpanded = !content.isExpanded;
component.forceRender++;
}}
>
{content.isExpanded ? (
<scale-icon-navigation-collapse-up
size={14}
></scale-icon-navigation-collapse-up>
) : (
<scale-icon-navigation-collapse-down
size={14}
></scale-icon-navigation-collapse-down>
)}
</scale-button>
)
);
},
};
36 changes: 23 additions & 13 deletions packages/components/src/components/data-grid/data-grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1118,6 +1118,14 @@ export class DataGrid {
}
// Add rows nested tables to array
if (field.type === 'html') {
if (!cellContent) {
return this.renderTableCell(
field,
null,
rowIndex,
columnIndex
);
}
if (!!cellContent.isExpanded) {
isNestedExpanded = true;
}
Expand Down Expand Up @@ -1148,20 +1156,22 @@ export class DataGrid {
<td class={`tbody__nested-cell`}>
{rowNestedContent.map(({ content }) => {
return (
<div
ref={(el) => {
if (el) {
// Remove content from other pages
let child = el.lastElementChild;
while (child) {
el.removeChild(child);
child = el.lastElementChild;
content && (
<div
ref={(el) => {
if (el) {
// Remove content from other pages
let child = el.lastElementChild;
while (child) {
el.removeChild(child);
child = el.lastElementChild;
}
// Append actual content
el.appendChild(content);
}
// Append actual content
el.appendChild(content);
}
}}
></div>
}}
></div>
)
);
})}
</td>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.