Auto-selection of full hash matches and dropdown visibility improvements - #1
Auto-selection of full hash matches and dropdown visibility improvements#1moijes12 wants to merge 2 commits into
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__`. Co-authored-by: moijes12 <4566851+moijes12@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
| useEffect(() => { | ||
| if (displayedRevisions.length < prevDisplayedRevisionsCount.current) { | ||
| setIsDropdownOpen(true); | ||
| } |
There was a problem hiding this comment.
@jules 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.
I have removed the logic that programmatically opens the revision dropdown when a selected revision is removed from view. I have also removed the corresponding test case for this behavior to avoid any conflicts with standard dropdown interactions (like clicking outside).
| const isPartialHash = | ||
| searchTerm.length >= 4 && /^[0-9a-fA-F]+$/.test(searchTerm); | ||
|
|
||
| if ( |
There was a problem hiding this comment.
@jules 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.
I have removed the !urlParams.has('newRev') condition. This ensures that the hash auto-selection works seamlessly on the Results page after a paste as well.
| } else if ( | ||
| results.length > 1 && | ||
| (isPartialHash || isFullHash) && | ||
| !urlParams.has('newRev') |
There was a problem hiding this comment.
@jules Same here. I'd remove this condition: !urlParams.has('newRev')
There was a problem hiding this comment.
I have removed the !urlParams.has('newRev') condition from this logic block as well.
|
@jules Please see the comments I have raised and act accordingly |
- 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.
This PR implements auto-selection for full and partial hash matches in the Search view, as requested in bug 1986319.
Key changes:
SearchAutoSelect.test.tsxwas added to ensure correct behavior and prevent regressions.Verified via
npm run test-alland visual inspection using Playwright scripts.PR created automatically by Jules for task 244443538767991578 started by @moijes12