From ce98863bbe15657d1dfbf485e91baf608bf11b7f Mon Sep 17 00:00:00 2001 From: Flaminia Cavallo Date: Tue, 12 Nov 2024 14:03:36 +0100 Subject: [PATCH] feat: when we have multiple sections, default to first section to avoid performance problems this is a temporary fix untill a proper fix will be in place --- cypress/e2e/context-selection/section-filter/index.js | 2 +- .../section-filter-selector-bar-item.js | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/cypress/e2e/context-selection/section-filter/index.js b/cypress/e2e/context-selection/section-filter/index.js index c8f977be1..8aa856c67 100644 --- a/cypress/e2e/context-selection/section-filter/index.js +++ b/cypress/e2e/context-selection/section-filter/index.js @@ -124,7 +124,7 @@ Then('that section should be selected', () => { Then('the "all sections" option should be selected', () => { cy.get('[data-test="section-filter-selector"]') - .contains('All sections') + .contains('Equipment') .should('exist') }) diff --git a/src/context-selection/section-filter-selector-bar-item/section-filter-selector-bar-item.js b/src/context-selection/section-filter-selector-bar-item/section-filter-selector-bar-item.js index ddb5e01fa..cdac27f94 100644 --- a/src/context-selection/section-filter-selector-bar-item/section-filter-selector-bar-item.js +++ b/src/context-selection/section-filter-selector-bar-item/section-filter-selector-bar-item.js @@ -28,8 +28,7 @@ export default function SectionFilterSelectorBarItem() { useEffect(() => { const sections = dataSet?.sections - // select first section if renderAsTabs === true - if (dataSet?.renderAsTabs && !sectionFilter && sections?.length) { + if (sectionFilter === undefined && sections?.length) { setSectionFilter(sections[0].id) } // clear out section if it is invalid @@ -55,9 +54,7 @@ export default function SectionFilterSelectorBarItem() { const selectableOptions = dataSet?.renderAsTabs ? sectionOptions - : [{ value: undefined, label: i18n.t('All sections') }].concat( - ...sectionOptions - ) + : [...sectionOptions, { value: null, label: i18n.t('All sections') }] return (