Skip to content

Commit e93ce92

Browse files
fix: always show all CRE links on CRE pages without collapsing (#901) (#909)
The issue was in CommonRequirementEnumeration.tsx — the collapse logic (slicing the list after 5 items and showing a "Show more" button) was being applied to all link types including CREs, with no distinction between CRE links and links to external standards. The fix adds an allLinksAreCres check that mirrors the same pattern already correctly implemented in DocumentNode.tsx. When all links in a group are of type CRE, the full list is shown without slicing and the "Show more" button is hidden. Links to external standards continue to collapse as before. Changes are limited to a single file: CommonRequirementEnumeration.tsx Added DOCUMENT_TYPES import from ../../const Compute allLinksAreCres before rendering each link group Use visibleResults (full list for CREs, sliced for others) instead of inline slice Guard the "Show more" button with !allLinksAreCres
1 parent 89b1643 commit e93ce92

1 file changed

Lines changed: 19 additions & 13 deletions

File tree

application/frontend/src/pages/CommonRequirementEnumeration/CommonRequirementEnumeration.tsx

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { Icon } from 'semantic-ui-react';
88
import { DocumentNode } from '../../components/DocumentNode';
99
import { ClearFilterButton, FilterButton } from '../../components/FilterButton/FilterButton';
1010
import { LoadingAndErrorIndicator } from '../../components/LoadingAndErrorIndicator';
11+
import { DOCUMENT_TYPES } from '../../const';
1112
import { useEnvironment } from '../../hooks';
1213
import { applyFilters, filterContext } from '../../hooks/applyFilters';
1314
import { Document } from '../../types';
@@ -106,25 +107,30 @@ export const CommonRequirementEnumeration = () => {
106107
const sortedResults = links.sort((a, b) =>
107108
getDocumentDisplayName(a.document).localeCompare(getDocumentDisplayName(b.document))
108109
);
110+
const allLinksAreCres =
111+
sortedResults.length > 0 &&
112+
sortedResults.every((link) => link.document.doctype === DOCUMENT_TYPES.TYPE_CRE);
113+
const visibleResults =
114+
allLinksAreCres || showAll[type]
115+
? sortedResults
116+
: sortedResults.slice(0, MAX_LENGTH_FOR_AUTO_EXPAND);
109117
return (
110118
<div className="cre-page__links" key={type}>
111119
<div className="cre-page__links-eader">
112120
<b>Which {getDocumentTypeText(type, links[0].document.doctype)}</b>:
113121
{/* Risk of mixed doctype in here causing odd output */}
114122
</div>
115-
{sortedResults
116-
.slice(0, showAll[type] ? sortedResults.length : MAX_LENGTH_FOR_AUTO_EXPAND)
117-
.map((link, i) => (
118-
<div
119-
key={i}
120-
className="accordion ui fluid styled cre-page__links-container"
121-
style={{ marginBottom: '4px' }}
122-
>
123-
<DocumentNode node={link.document} linkType={type} />
124-
<FilterButton document={link.document} />
125-
</div>
126-
))}
127-
{sortedResults.length > MAX_LENGTH_FOR_AUTO_EXPAND && (
123+
{visibleResults.map((link, i) => (
124+
<div
125+
key={i}
126+
className="accordion ui fluid styled cre-page__links-container"
127+
style={{ marginBottom: '4px' }}
128+
>
129+
<DocumentNode node={link.document} linkType={type} />
130+
<FilterButton document={link.document} />
131+
</div>
132+
))}
133+
{!allLinksAreCres && sortedResults.length > MAX_LENGTH_FOR_AUTO_EXPAND && (
128134
<button
129135
onClick={() => setShowAll((prev) => ({ ...prev, [type]: !prev[type] }))}
130136
style={{ marginTop: '8px', cursor: 'pointer' }}

0 commit comments

Comments
 (0)