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

[Resolve Errors] [Review Warnings] Tables - full borders will only show when overflowing (horizontal scrolling active) #583

Merged
merged 3 commits into from
May 28, 2024
Merged
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
200 changes: 100 additions & 100 deletions .pnp.cjs

Large diffs are not rendered by default.

Binary file not shown.
19 changes: 8 additions & 11 deletions src/pages/Filing/FilingApp/FieldEntry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useState } from 'react';
import Markdown from 'react-markdown';
import type { Detail, Field } from 'types/filingTypes';
import { Hundred, ITEMS_PER_PAGE, One } from 'utils/constants';
import useIsOverflowing from 'utils/useIsOverflowing';

// NOTE: To be removed after table styling finalized
const maxUidTestRows = [...Array.from({ length: Hundred }).keys()].map(
Expand All @@ -26,13 +27,9 @@ const wordBreakTestRows = [

interface FieldEntryProperties {
fieldObject: Detail;
showTableBorders?: boolean;
}

function FieldEntry({
fieldObject,
showTableBorders,
}: FieldEntryProperties): JSX.Element {
function FieldEntry({ fieldObject }: FieldEntryProperties): JSX.Element {
// TODO: selectively enable borders based on if the table is overflowing
// Issue: https://github.com/cfpb/sbl-frontend/issues/547
// const [multiTableReference, isMultiTableOverflowing] = useIsOverflowing();
Expand Down Expand Up @@ -104,6 +101,10 @@ function FieldEntry({
setCurrentPage(inputNumber);
};

// Selectively enable full table borders based on if the table's wrapper div is overflowing
const [tableDivReference, tableDivReferenceIsOverflowing] =
useIsOverflowing();
shindigira marked this conversation as resolved.
Show resolved Hide resolved

return (
<div className='mb-[2.8125rem]'>
<div className='validation-info-section mb-[1.875rem] max-w-[41.875rem]'>
Expand All @@ -121,14 +122,14 @@ function FieldEntry({
<div className='mb-[0.9375rem]'>
<Table
className={`w-full max-w-full table-auto ${
showTableBorders ? '' : '!border-0'
tableDivReferenceIsOverflowing ? '' : '!border-0'
}`}
columns={columns}
// @ts-expect-error TypeScript error needs to be resolved within DSR
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
rows={itemsToShow}
isScrollableHorizontal
// ref={multiTableReference}
ref={tableDivReference}
/>
{/* NOTE: Table used to create space */}
{isHiddenTableAdded ? (
Expand All @@ -155,8 +156,4 @@ function FieldEntry({
);
}

FieldEntry.defaultProps = {
showTableBorders: false,
};

export default FieldEntry;
9 changes: 1 addition & 8 deletions src/pages/Filing/FilingApp/FieldSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ interface FieldProperties {
bottomMargin?: boolean;
children: ReactNode;
id: string;
showTableBorders?: boolean;
}

function FieldSummary({
Expand All @@ -19,7 +18,6 @@ function FieldSummary({
children,
id,
className = '',
showTableBorders,
}: FieldProperties & JSX.IntrinsicElements['div']): JSX.Element {
return (
<div
Expand All @@ -30,19 +28,14 @@ function FieldSummary({
{children}
</SectionIntro>
{fieldArray.map(fieldObject => (
<FieldEntry
key={fieldObject.validation.id}
fieldObject={fieldObject}
showTableBorders={showTableBorders}
/>
<FieldEntry key={fieldObject.validation.id} fieldObject={fieldObject} />
))}
</div>
);
}

FieldSummary.defaultProps = {
bottomMargin: false,
showTableBorders: false,
};

export default FieldSummary;
1 change: 0 additions & 1 deletion src/pages/Filing/FilingApp/FilingErrors/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ function FilingErrors(): JSX.Element {
id='multi-field-errors'
heading={`Multi-field errors: ${multiFieldRowErrorsCount.toLocaleString()} found`}
fieldArray={logicErrorsMulti}
showTableBorders
bottomMargin
>
Multi-field validations check that the values of certain
Expand Down
1 change: 0 additions & 1 deletion src/pages/Filing/FilingApp/FilingWarnings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ function FilingWarnings(): JSX.Element {
id='multi-field-warnings'
heading={`Multi-field warnings: ${multiFieldRowWarningsCount.toLocaleString()} found`}
fieldArray={logicWarningsMulti}
showTableBorders
bottomMargin
>
Multi-field validations check that the values of certain fields
Expand Down
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5562,7 +5562,7 @@ __metadata:

"design-system-react@https://github.com/cfpb/design-system-react":
version: 0.0.0
resolution: "design-system-react@https://github.com/cfpb/design-system-react.git#commit=a7eb40a6d8a2faa59ad2655a83732b97be16406b"
resolution: "design-system-react@https://github.com/cfpb/design-system-react.git#commit=c04021288110c5d15f06b2c33c4a8de27c23eb76"
dependencies:
"@cfpb/cfpb-design-system": ^0.35.0
"@cfpb/cfpb-expandables": ^0.35.0
Expand All @@ -5574,7 +5574,7 @@ __metadata:
react-dom: 18.2.0
react-router-dom: 6.3.0
react-select: ^5.7.2
checksum: ab171d1cc6c1887d3871780072a79c5a40b9960a62c4af68d62d0ddc70958c2b59ae35462aaf53c34c65989c61a6580301facaa640eb5ced208f587a61da4de9
checksum: e3f22b32ccd03b3a80396fd4769dce9cc085fd02d938fb5f6d9e1e1608f1b60d56e40cd3746e3c5b569595ec12417ee743ca431f64de97b5e31d9e794325229e
languageName: node
linkType: hard

Expand Down