Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

[terra-table] Adding subsections to sections #2112

Merged
merged 54 commits into from
Apr 9, 2024
Merged

Conversation

BenBoersma
Copy link
Contributor

Summary

Adding subsections to sections which include a section header.

What was changed:

Why it was changed:

Testing

This change was tested using:

  • WDIO
  • Jest
  • Visual testing (please attach a screenshot or recording)
  • Other (please describe below)
  • No tests are needed

Reviews

In addition to engineering reviews, this PR needs:

  • UX review
  • Accessibility review
  • Functional review

Additional Details

This PR resolves:
Partially resolves.
UXPLATFORM-10224


Thank you for contributing to Terra.
@cerner/terra

@sdadn sdadn marked this pull request as ready for review April 1, 2024 15:27
@sdadn sdadn self-assigned this Apr 1, 2024
Copy link
Contributor

@adoroshk adoroshk left a comment

Choose a reason for hiding this comment

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

Some CSS observations

  1. Lowlight theme styling looks off to me:
Screenshot 2024-04-02 at 10 44 26 AM 2. NIT (if that is expect behavior - please disregard it), subsection header text alignment is not exactly aligned with section header (or anything else) on the left. It is placed much more to the right than the rest of the content. Screenshot 2024-04-02 at 10 47 03 AM Screenshot 2024-04-02 at 10 47 53 AM

Copy link
Contributor

@adoroshk adoroshk left a comment

Choose a reason for hiding this comment

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

To make sure we are on the same page I wanted to double-check that subsections are going to be supported on table only in not supported in Grids. If that's correct, that should be also mentioned in documentation. In case I am wrong and subsections are supported in grids, there should be grid examples and tests added.

@@ -0,0 +1,90 @@
// TODO: fix linter error
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this TODO addressed, or is it out of scope of this PR?

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like it was from a previous PR but there doesn't seem to be any linter issues. Removed here: 86bd928

/**
* An array of subsections objects to be rendered within the section.
*/
subsections: PropTypes.arrayOf(subsectionShape),
Copy link
Contributor

Choose a reason for hiding this comment

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

A documentation update is needed per subsection property added to the section shape here:

import PropTypes from 'prop-types';
import rowShape from './rowShape';

const sectionShape = PropTypes.shape({
Copy link
Contributor

Choose a reason for hiding this comment

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

A documentation page needs to be updated with section shape info similar to the way we have for section

Copy link
Contributor

Choose a reason for hiding this comment

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

Added here: 2395c42

};

return (
<Table
Copy link
Contributor

Choose a reason for hiding this comment

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

I would add this example to user facing part of the documentation as well, so that users have access to the implementation code example.

@sdadn
Copy link
Contributor

sdadn commented Apr 2, 2024

To make sure we are on the same page I wanted to double-check that subsections are going to be supported on table only in not supported in Grids. If that's correct, that should be also mentioned in documentation. In case I am wrong and subsections are supported in grids, there should be grid examples and tests added.

I believe subsections are only for flowsheet datagrids (@mjpalazzo is that correct?). Consuming these changes in flowsheet will be done in a separate PR.

@github-actions github-actions bot temporarily deployed to preview-pr-2112 April 2, 2024 17:14 Destroyed
@mjpalazzo
Copy link
Contributor

To make sure we are on the same page I wanted to double-check that subsections are going to be supported on table only in not supported in Grids. If that's correct, that should be also mentioned in documentation. In case I am wrong and subsections are supported in grids, there should be grid examples and tests added.

I believe subsections are only for flowsheet datagrids (@mjpalazzo is that correct?). Consuming these changes in flowsheet will be done in a separate PR.

That is correct. Flowsheet only

@cm9361
Copy link
Contributor

cm9361 commented Apr 2, 2024

There doesn't appear to be a new or updated example to show how to implement subsections.

.orion-fusion-theme {
--terra-table-subsection-font-size: 0.808571428571rem;
--terra-table-subsection-font-weight: 700;
--terra-table-subsection-font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't we be using the base font family? I wouldn't expect us to have to define this in our sass file.

Copy link
Contributor

Choose a reason for hiding this comment

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

Removed here: 6ee7c59

Comment on lines 13 to 14
padding-top: 0.3571428571rem;
padding-bottom: 0.3571428571rem;
Copy link
Contributor

Choose a reason for hiding this comment

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

I would expect the padding to be themeable as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

Added here: 29bba90

Comment on lines 72 to 80
<h3
className={cx('subsection')}
>
<span
className={cx('sticky')}
>
{text}
</span>
</h3>
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we be using the SectionHeader Terra component here?

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe @BenBoersma tried that but terra section header doesn't have the subsection styling guidelines provided by UX.

Copy link
Contributor

Choose a reason for hiding this comment

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

Disregard this, managed to override the styles of terra-section-header.

</h3>
</th>
</tr>
</>
Copy link
Contributor

Choose a reason for hiding this comment

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

Where is the content for the subsection?

Comment on lines 225 to 245
{!isCollapsed && subsection.rows.map((row, rowIndex) => (
<Row
rowIndex={subsection.subSectionRowIndex + (rowIndex + 1)}
key={row.id}
height={rowHeight}
id={row.id}
sectionId={!isHidden ? id : undefined}
tableId={tableId}
cells={row.cells}
ariaLabel={row.ariaLabel}
rowSelectionMode={rowSelectionMode}
displayedColumns={displayedColumns}
rowHeaderIndex={rowHeaderIndex}
onCellSelect={onCellSelect}
isSelected={row.isSelected}
isTableStriped={isTableStriped}
rowMinimumHeight={rowMinimumHeight}
firstRowId={firstRowId}
lastRowId={lastRowId}
/>
))}
Copy link
Contributor

Choose a reason for hiding this comment

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

The SubSection component should be rendering its own rows.

@github-actions github-actions bot temporarily deployed to preview-pr-2112 April 3, 2024 11:30 Destroyed
@sdadn
Copy link
Contributor

sdadn commented Apr 3, 2024

There doesn't appear to be a new or updated example to show how to implement subsections.

@cm9361 This PR only adds subsection support for terra-table. Consuming that in flowsheet and adding documentation for consumers will be done in the next PR.

@github-actions github-actions bot temporarily deployed to preview-pr-2112 April 3, 2024 11:48 Destroyed
@github-actions github-actions bot temporarily deployed to preview-pr-2112 April 3, 2024 18:51 Destroyed
@github-actions github-actions bot temporarily deployed to preview-pr-2112 April 9, 2024 13:33 Destroyed
@@ -387,6 +393,7 @@ function Cell(props) {
const columnHeaderId = `${tableId}-${columnId}-headerCell`;
const rowHeaderId = !isRowHeader && rowHeaderIndex !== -1 ? `${tableId}-rowheader-${rowId} ` : '';
const sectionHeaderId = sectionId ? `${tableId}-${sectionId} ` : '';
const subsectionHeaderId = subsectionId ? `${tableId}-${sectionId}-${subsectionId} ` : '';
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need the section id in the id for the subsection?

Copy link
Contributor

Choose a reason for hiding this comment

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

I added it so we'll know which section the subsection is associated with. Do we need that or is the section id redundant?

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess having the section helps to ensure uniqueness.

Copy link
Contributor

Choose a reason for hiding this comment

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

It does not appear that the onCellSelect method has been updated to include the subsection id.

Copy link
Contributor

Choose a reason for hiding this comment

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

fixed here: a981a90

tableId,
};

if (subsections) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What happens if the section has its own rows as well as subsections? I don't believe that use case is covered in this design.

Copy link
Contributor

Choose a reason for hiding this comment

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

From my understanding, a section would have either rows or subsections but not both. If both are passed in, then the rows will be ignored and not rendered. Does that meet the requirements? cc @mjpalazzo .

Copy link
Contributor

Choose a reason for hiding this comment

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

Subsections definitely can have rows. See screen shot.
image

Copy link
Contributor

Copy link
Contributor

Choose a reason for hiding this comment

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

The subsections are used to show the routing of medication orders. There is typically a row under the subsection for each medication that qualifies for that route; e.g., electronic prescription, pharmacy call, etc.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh I meant if section level row and subsections are both simultaneously possible?

e.g.

  • section header
    • section row
    • section row
    • subsection
      • subsection row
      • subsection row 2

Copy link
Contributor

Choose a reason for hiding this comment

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

I will have to reach out the Clinical product manager for that question.

text={subsection.text}
isTitleSticky
boundedWidth={boundingWidth}
level={3}
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like the value of 3 should be a constant so that we can give a meaningful name to the value.

Copy link
Contributor

Choose a reason for hiding this comment

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

Added constant in a018196

Comment on lines 256 to 257
collapsed: isCollapsed,
collapsible: isCollapsible,
Copy link
Contributor

@cm9361 cm9361 Apr 9, 2024

Choose a reason for hiding this comment

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

Subsections are not collapsible. We should not need classes on the subsection. The subsection visibility should be covered by the parent section. We shouldn't even render subsections or their header rows if the section is collapsed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Subsections don't get rendered, as confirmed by this test. But I can remove these classes if they are redundant.

it('validates a table with with collapsed sections', () => {
browser.url('/raw/tests/cerner-terra-framework-docs/table/table-with-collapsible-sections-and-sub-sections');
expect(browser.$('//*[@id="table-with-sub-sections"]/tbody[3]')).toHaveChildren(2);
Terra.validates.element('table-with-collasped-subsections', { selector: tableWithSubSectionsSelector });
});

Copy link
Contributor

Choose a reason for hiding this comment

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

Removed redundant css here: 0fc369b

>

<SectionHeader
className={cx('subsection')}
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this class be something like subsection-header-row to match the section classes?

Copy link
Contributor

@sdadn sdadn Apr 9, 2024

Choose a reason for hiding this comment

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

This appends the subsection class to the existing header-row class, so it would be header-row subsection, but I can rename it if it's preferred.

Copy link
Contributor

Choose a reason for hiding this comment

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

Renamed it here: e94e26b

</th>
</tr>
</tbody>
<tbody className={cx('subsection-rows', {
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems like this would be the subsection class.

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like this is not needed, removed here: 0fc369b

@cm9361
Copy link
Contributor

cm9361 commented Apr 9, 2024

Doesn't the isSection method in the DataGrid component need to be updated to account for the new subsections? If that is done, does that fix all your keyboard navigation issues?

<tr
aria-rowindex={subsection.subSectionRowIndex}
className={cx('header-row', theme.className)}
data-section-id={id}
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be data-subsection-id or something similar? This would not technically be a section, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

Fixed here: d1c988e

@github-actions github-actions bot temporarily deployed to preview-pr-2112 April 9, 2024 15:36 Destroyed
@github-actions github-actions bot temporarily deployed to preview-pr-2112 April 9, 2024 16:27 Destroyed
@sdadn
Copy link
Contributor

sdadn commented Apr 9, 2024

Some CSS observations

  1. Lowlight theme styling looks off to me:
  2. NIT (if that is expect behavior - please disregard it), subsection header text alignment is not exactly aligned with section header (or anything else) on the left. It is placed much more to the right than the rest of the content.

@adoroshk

  1. I have corrected the lowlight styling, thanks for pointing that out!
  2. The offset is by design from UX.

@sdadn
Copy link
Contributor

sdadn commented Apr 9, 2024

Doesn't the isSection method in the DataGrid component need to be updated to account for the new subsections? If that is done, does that fix all your keyboard navigation issues?

@cm9361 I haven't been able to work on the DataGrid component yet. So far, I've mainly been focusing on adding support for subsections to the Table component for this Jira & PR.

@github-actions github-actions bot temporarily deployed to preview-pr-2112 April 9, 2024 18:22 Destroyed
@github-actions github-actions bot temporarily deployed to preview-pr-2112 April 9, 2024 21:30 Destroyed
@sdadn sdadn merged commit c44438d into main Apr 9, 2024
20 of 21 checks passed
@sdadn sdadn deleted the adding-table-subsections branch April 9, 2024 21:56
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants