fix: exact match appears first in multi-select modality filter #5538
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context
This PR fixes an issue where typing a modality option like "US" in the multi-select dropdown would list partial match modalities before the exact match.
Fixes #5534
Problem
The react-select component keeps the original option order for modalities (as defined in filtersMeta.js) and does not prioritize exact matches when filtering.
This default behavior caused unexpected results, for example, typing "US" matched both "US" and "BDUS", but "BDUS" appeared first by default.
Changes
Introduced a controlled inputValue state to track user input.
Used useMemo to sort options in the following order: Exact match, Partial match, Alphabetical fallback
Updated the react-select component to use the sorted list.
Results
The modalities worklist filter prioritize the exact match.
For example, when typing "US":

Before: it will show "BDUS" first and on pressing Enter selects "BDUS"
After: it will show "US" first and on pressing Enter selects "US"

Testing
open Viewer landing page
on modality multi-select filter, type US
confirm that: US appears first in the dropdown list
pressing Enter selects US
Checklist
PR
semantic-release format and guidelines.
Code
etc.)
Public Documentation Updates
additions or removals.
Tested Environment