Skip to content

Commit

Permalink
Merge pull request #421 from dhis2/DHIS2-18405/default-to-first-section
Browse files Browse the repository at this point in the history
feat: when we have multiple sections, default to first section
  • Loading branch information
flaminic authored Nov 13, 2024
2 parents b5be111 + ce98863 commit 8818548
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cypress/e2e/context-selection/section-filter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 (
<div data-test="section-filter-selector">
Expand Down

1 comment on commit 8818548

@dhis2-bot
Copy link
Contributor

Choose a reason for hiding this comment

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

Please sign in to comment.