Skip to content

Prevent removal of already removed menu sections from throwing errors - #4539

Merged
tdonohue merged 2 commits into
DSpace:mainfrom
alexandrevryghem:handle-non-existing-menu-section-removal-error_contribute-main
Mar 2, 2026
Merged

Prevent removal of already removed menu sections from throwing errors#4539
tdonohue merged 2 commits into
DSpace:mainfrom
alexandrevryghem:handle-non-existing-menu-section-removal-error_contribute-main

Conversation

@alexandrevryghem

Copy link
Copy Markdown
Member

Description

Fixed an issue where the menu reducer could throw an error when you tried to delete an already deleted menu section. This can occur when you remove all the menu sections individually, and the parent section gets deleted before all its child sections are removed. This is because the deletion of a parent menu also removes all it's child sections (see menu.reducer.ts#removeFromIndex), and when you try to remove an already deleted menu section, an error will be thrown.

Instructions for Reviewers

List of changes in this PR:

  • Simply added an hasNoValue check to prevent the menu.reducer.ts#removeFromIndex from throwing an error when a section doesn't exist anymore

Guidance for how to review this PR.
This error is not directly reproducible in default DSpace but it's a nice safeguard. To review, simply verify that the regular menu providers are not affected by this new condition, and that the new test succeeds

Checklist

  • My PR is created against the main branch of code (unless it is a backport or is fixing an issue specific to an older branch).
  • My PR is small in size (e.g. less than 1,000 lines of code, not including comments & specs/tests), or I have provided reasons as to why that's not possible.
  • My PR passes ESLint validation using npm run lint
  • My PR doesn't introduce circular dependencies (verified via npm run check-circ-deps)
  • My PR includes TypeDoc comments for all new (or modified) public methods and classes. It also includes TypeDoc for large or complex private methods.
  • My PR passes all specs/tests and includes new/updated specs or tests based on the Code Testing Guide.
  • My PR aligns with Accessibility guidelines if it makes changes to the user interface.
  • My PR uses i18n (internationalization) keys instead of hardcoded English text, to allow for translations.
  • My PR includes details on how to test it. I've provided clear instructions to reviewers on how to successfully test this fix or feature.
  • If my PR includes new libraries/dependencies (in package.json), I've made sure their licenses align with the DSpace BSD License based on the Licensing of Contributions documentation.
  • If my PR includes new features or configurations, I've provided basic technical documentation in the PR itself.
  • If my PR fixes an issue ticket, I've linked them together.

@alexandrevryghem alexandrevryghem self-assigned this Jul 10, 2025
@alexandrevryghem alexandrevryghem added quick win Pull request is small in size & should be easy to review and/or merge port to dspace-7_x port to dspace-8_x This PR needs to be ported to `dspace-8_x` branch for next bug-fix release port to dspace-9_x This PR needs to be ported to `dspace-9_x` branch for next bug-fix release labels Jul 10, 2025
@tdonohue tdonohue moved this to 🙋 Needs Reviewers Assigned in DSpace 10.0 Release Jul 10, 2025
@tdonohue tdonohue added the 1 APPROVAL pull request only requires a single approval to merge label Jul 10, 2025
@github-actions

Copy link
Copy Markdown

Hi @alexandrevryghem,
Conflicts have been detected against the base branch.
Please resolve these conflicts as soon as you can. Thanks!

@alexandrevryghem
alexandrevryghem force-pushed the handle-non-existing-menu-section-removal-error_contribute-main branch from 4bb11c0 to cfb4fea Compare November 30, 2025 22:44
@alegontarz

Copy link
Copy Markdown

QA testing performed (no code review).

Working as expected:

  1. Main navigation menu loads correctly.
  2. Admin and user menus display and expand/collapse properly.
  3. Menu links navigate correctly.
  4. No console errors observed during navigation.

No visible regressions in existing menu providers.

@tdonohue tdonohue moved this from 🙋 Needs Reviewers Assigned to 👍 Reviewer Approved in DSpace 10.0 Release Feb 20, 2026

@tdonohue tdonohue left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

👍 Thanks @alexandrevryghem ! The code looks good to me, along with the new specs. As this has been tested by @alegontarz (thanks as well!) this looks good to me.

@tdonohue tdonohue added this to the 10.0 milestone Mar 2, 2026
@tdonohue
tdonohue merged commit d8ea226 into DSpace:main Mar 2, 2026
15 checks passed
@github-project-automation github-project-automation Bot moved this from 👍 Reviewer Approved to ✅ Done in DSpace 10.0 Release Mar 2, 2026
@dspace-bot

Copy link
Copy Markdown
Contributor

Backport failed for dspace-7_x, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin dspace-7_x
git worktree add -d .worktree/backport-4539-to-dspace-7_x origin/dspace-7_x
cd .worktree/backport-4539-to-dspace-7_x
git switch --create backport-4539-to-dspace-7_x
git cherry-pick -x 2f051276ce6c7a6d466001cb2a6a01cbd7ec8b4b

@dspace-bot

Copy link
Copy Markdown
Contributor

Successfully created backport PR for dspace-8_x:

@dspace-bot

Copy link
Copy Markdown
Contributor

Successfully created backport PR for dspace-9_x:

@tdonohue tdonohue removed port to dspace-7_x port to dspace-8_x This PR needs to be ported to `dspace-8_x` branch for next bug-fix release port to dspace-9_x This PR needs to be ported to `dspace-9_x` branch for next bug-fix release labels Mar 2, 2026
@alexandrevryghem
alexandrevryghem deleted the handle-non-existing-menu-section-removal-error_contribute-main branch March 2, 2026 23:30
@damian-joz
damian-joz requested a review from alegontarz March 17, 2026 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1 APPROVAL pull request only requires a single approval to merge quick win Pull request is small in size & should be easy to review and/or merge

Projects

No open projects
Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

4 participants