Bug 1986319: Auto-select for full hash matches#1066
Conversation
- Automatically select a revision when a full 40-character hash or a partial hex hash (length >= 4) matches exactly one result or matches a result's revision hash. - Ensure the revision dropdown remains open after auto-selecting a full 40-character hash. - Automatically open the revision dropdown when a selected revision is removed from the view. - Added a new test suite `src/__tests__/Search/SearchAutoSelect.test.tsx` to verify these behaviors. - Updated existing snapshots in `src/__tests__/Search/__snapshots__`.
Updating screenshots
✅ Deploy Preview for mozilla-perfcompare ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
kala-moz
left a comment
There was a problem hiding this comment.
Thanks for cleaning this up. I left a comment below regarding the dropdown behavior.
| } | ||
| prevDisplayedRevisionsCount.current = displayedRevisions.length; | ||
| }, [displayedRevisions]); | ||
|
|
There was a problem hiding this comment.
Hi Alex, so this behavior is unwanted in the app. When a selected revision is removed from view, we don't want to open the revision dropdown. This also conflicts with closing the revision dropdown when the user clicks outside the component. We'll also have to remove the test for this behavior too.
There was a problem hiding this comment.
Changed implemented in latest commit
| if ( | ||
| results.length === 1 && | ||
| (isPartialHash || isFullHash) && | ||
| !urlParams.has('newRev') |
There was a problem hiding this comment.
We want to select the revision after pasting the hash on the Results page too, so I'd remove this condition: !urlParams.has('newRev')
There was a problem hiding this comment.
Changed implemented in latest commit
| } else if ( | ||
| results.length > 1 && | ||
| (isPartialHash || isFullHash) && | ||
| !urlParams.has('newRev') |
There was a problem hiding this comment.
Same here; I'd remove this condition: !urlParams.has('newRev')
There was a problem hiding this comment.
Changed implemented in latest commit
- Removed the logic that opens the dropdown when a selected revision is removed from the view, resolving conflicts with standard clicking outside interactions.
- Removed the test case for the dropdown opening upon revision removal.
- Removed the `!urlParams.has('newRev')` condition to allow hash auto-selection to work on the Results page after pasting a hash.
- Ran all tests successfully and updated snapshots.
|
Thanks @kala-moz . I have implemented the changes requested in the latest commit |
Overview
Automatically select a single matching revision from search results (partial or full hash), and keep the autocomplete dropdown open when a full 40-char hash is pasted. Also reopen the dropdown when a selected revision is removed. Adds tests and updates snapshots.
Changes Introduced
Files Modified
src/components/Search/SearchInputAndResults.tsx: added isDropdownOpen state, refs, effects, and open/onOpen/onClose handlers; updated input/change handlers and selection logic.src/tests/Search/SearchAutoSelect.test.tsx: tests for auto-selection and dropdown behavior.Testing
Fixes Bug-1986319
@kala-moz @beatrice-acasandrei