Skip to content

Fix: Scrollable dropdown does not highlight current selection (#4958)#5020

Merged
tdonohue merged 1 commit intoDSpace:mainfrom
solomona2003:fix/scrollable-dropdown-selection
Feb 6, 2026
Merged

Fix: Scrollable dropdown does not highlight current selection (#4958)#5020
tdonohue merged 1 commit intoDSpace:mainfrom
solomona2003:fix/scrollable-dropdown-selection

Conversation

@solomona2003
Copy link
Contributor

@solomona2003 solomona2003 commented Jan 21, 2026

Description

Fixes #4958

This PR fixes two issues with the scrollable dropdown component:

  1. Selection highlighting: The currently selected item is now properly highlighted when the dropdown is reopened
  2. Dynamic loading: Dropdown items are loaded based on actual vocabulary size

Changes Made

Selection Highlighting

  • Highlight current value when menu opens (setSelectedIndexToCurrentValue)
  • Treat 'Clear selection' as index 0, adjust item indices (i+1)
  • Arrow key navigation respects clear item (totalItems)
  • Enter selects correct item or clears when index = 0
  • Skip disabled items in scrollToSelected
  • Selected items now highlighted correctly up to position 200

Dynamic Loading

  • Uses actual vocabulary size from pageInfo.totalElements
  • Caps at 200 items to prevent loading huge vocabularies
  • Performance scaled: 50 items (Good UX), 100 items (Acceptable), 200 items (Borderline)

Testing

Tested with submission forms using Type and Language dropdowns.

Checklist

This checklist provides a reminder of what we are going to look for when reviewing your PR. You do not need to complete this checklist prior creating your PR (draft PRs are always welcome).
However, reviewers may request that you complete any actions in this list if you have not done so. If you are unsure about an item in the checklist, don't hesitate to ask. We're here to help!

  • [ X ] 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).
  • [ X ] 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.
  • [ X ] My PR passes ESLint validation using npm run lint
  • [ X ] My PR doesn't introduce circular dependencies (verified via npm run check-circ-deps)
  • [ X ] My PR includes TypeDoc comments for all new (or modified) public methods and classes. It also includes TypeDoc for large or complex private methods.
  • [ X ] My PR passes all specs/tests and includes new/updated specs or tests based on the Code Testing Guide.
  • [ X ] 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.
  • [ X ] If my PR fixes an issue ticket, I've linked them together.

Dynamic Loading:
- Uses actual vocabulary size from pageInfo.totalElements
- Caps at 200 items to prevent loading huge vocabularies
- Performance scaled: 50 items (Good UX), 100 items (Acceptable), 200 items (Borderline)

Selection Highlighting:
- Highlight current value when menu opens (setSelectedIndexToCurrentValue)
- Treat 'Clear selection' as index 0, adjust item indices (i+1)
- Arrow key navigation respects clear item (totalItems)
- Enter selects correct item or clears when index = 0
- Skip disabled items in scrollToSelected
- Selected items now highlighted correctly up to position 200# This is the 1st commit message:
@solomona2003 solomona2003 force-pushed the fix/scrollable-dropdown-selection branch from 594e1bc to 44a3fcd Compare January 21, 2026 19:11
@tdonohue tdonohue added bug usability component: submission 1 APPROVAL pull request only requires a single approval to merge port to dspace-9_x This PR needs to be ported to `dspace-9_x` branch for next bug-fix release labels Jan 21, 2026
@tdonohue tdonohue moved this to 🙋 Needs Reviewers Assigned in DSpace 10.0 Release Jan 21, 2026
@lgeggleston
Copy link

Hi! Tested this fix via the Type and Language dropdowns, looks good and works as expected. Nice catch on the keyboard navigation to 'Clear selection' too!

Also adding backport tags to 8.x and 7.x; after comparing code it looks like this fix should be able to auto backport smoothly.

@lgeggleston lgeggleston added port to dspace-7_x This PR needs to be ported to `dspace-7_x` branch for next bug-fix release port to dspace-8_x This PR needs to be ported to `dspace-8_x` branch for next bug-fix release accessibility labels Feb 4, 2026
@lgeggleston lgeggleston moved this from 🙋 Needs Reviewers Assigned to 👍 Reviewer Approved in DSpace 10.0 Release Feb 4, 2026
Copy link
Member

@tdonohue tdonohue left a comment

Choose a reason for hiding this comment

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

👍 Thanks @solomona2003 ! The code looks good to me, and glad to see that @lgeggleston tested it thoroughly

@tdonohue tdonohue added this to the 10.0 milestone Feb 6, 2026
@tdonohue tdonohue merged commit ef8b124 into DSpace:main Feb 6, 2026
16 checks passed
@github-project-automation github-project-automation bot moved this from 👍 Reviewer Approved to ✅ Done in DSpace 10.0 Release Feb 6, 2026
@dspace-bot
Copy link
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-5020-to-dspace-7_x origin/dspace-7_x
cd .worktree/backport-5020-to-dspace-7_x
git switch --create backport-5020-to-dspace-7_x
git cherry-pick -x 44a3fcd7d5808d61caa8af5432487841cb8490b1

@dspace-bot
Copy link
Contributor

Backport failed for dspace-8_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-8_x
git worktree add -d .worktree/backport-5020-to-dspace-8_x origin/dspace-8_x
cd .worktree/backport-5020-to-dspace-8_x
git switch --create backport-5020-to-dspace-8_x
git cherry-pick -x 44a3fcd7d5808d61caa8af5432487841cb8490b1

@dspace-bot
Copy link
Contributor

Successfully created backport PR for dspace-9_x:

@tdonohue
Copy link
Member

tdonohue commented Feb 6, 2026

@solomona2003 : We were able to auto-backport this to 9.x. But, the backports to 8.x and 7.x failed. This will need to wait on a volunteer to backport it further. Please let me know if you are interested in backporting this to our dspace-8_x or dspace-7_x branches.

Thanks again!

@tdonohue tdonohue removed the port to dspace-9_x This PR needs to be ported to `dspace-9_x` branch for next bug-fix release label Feb 6, 2026
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 accessibility bug component: submission port to dspace-7_x This PR needs to be ported to `dspace-7_x` branch for next bug-fix release port to dspace-8_x This PR needs to be ported to `dspace-8_x` branch for next bug-fix release usability

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

Scrollable dropdown does not highlight current selection

4 participants