Skip to content

Bug-1986319: Allow auto selection of full hash matches#1024

Open
moijes12 wants to merge 2 commits intomozilla:mainfrom
moijes12:bug1986319
Open

Bug-1986319: Allow auto selection of full hash matches#1024
moijes12 wants to merge 2 commits intomozilla:mainfrom
moijes12:bug1986319

Conversation

@moijes12
Copy link
Copy Markdown
Contributor

@moijes12 moijes12 commented Apr 6, 2026

Updated SearchInputAndResults to:

  • Track input value as state
  • Check if the input is a hash and if it matches an existing hash
  • Auto select the hash if it matches the full hash

@kala-moz @beatrice-acasandrei

Fixes Bug-1986319

@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 6, 2026

Deploy Preview for mozilla-perfcompare ready!

Name Link
🔨 Latest commit a9e2973
🔍 Latest deploy log https://app.netlify.com/projects/mozilla-perfcompare/deploys/69dd09d360d576000812966c
😎 Deploy Preview https://deploy-preview-1024--mozilla-perfcompare.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.22%. Comparing base (8c8a149) to head (a9e2973).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1024      +/-   ##
==========================================
+ Coverage   96.19%   96.22%   +0.02%     
==========================================
  Files         111      111              
  Lines        3155     3178      +23     
  Branches      712      719       +7     
==========================================
+ Hits         3035     3058      +23     
  Misses        118      118              
  Partials        2        2              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@kala-moz kala-moz self-requested a review April 7, 2026 22:59
}, []);

// Helper to check if the search term matches a full 40 character revision hash
const isFullRevisionHash = (searchTerm: string) =>
Copy link
Copy Markdown
Contributor

@beatrice-acasandrei beatrice-acasandrei Apr 8, 2026

Choose a reason for hiding this comment

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

Since we are permitting partial searches (by short hash), this improvement should also apply to short hashes, not solely to full revision hashes.

Note: This request improvement was added by me in bugzilla, but it is actually something that came up in our latest feedback google form. It's missing some details and it was anonymous, so we'll need to make some decisions regarding the behaviour.

@kala-moz What do you think?

Copy link
Copy Markdown
Contributor

@kala-moz kala-moz Apr 10, 2026

Choose a reason for hiding this comment

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

@beatrice-acasandrei I agree with your comment on the bug. The behavior should remain the same except now the checkbox is checked and the revision is shown in the component after the hash is pasted. This should also work for short hashes.

@kala-moz
Copy link
Copy Markdown
Contributor

kala-moz commented Apr 9, 2026

@moijes12 I've run out of time today so I'll review this tomorrow!

@moijes12
Copy link
Copy Markdown
Contributor Author

moijes12 commented Apr 9, 2026

@moijes12 I've run out of time today so I'll review this tomorrow!

Sure Kala.

Copy link
Copy Markdown
Contributor

@kala-moz kala-moz left a comment

Choose a reason for hiding this comment

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

Thanks for taking this on! Right now this somewhat works for full hashes. The problem is that after pasting the full hash, the revision dropdown doesn't appear below the search input so the user can't change their selection. And if the user manually deletes the revision from the view, the revision dropdown still doesn't appear. The user is stuck with their original selection. We'll have to investigate why this happens. And like Beatrice said, this should also work for short hashes.

@moijes12
Copy link
Copy Markdown
Contributor Author

Thanks @kala-moz and @beatrice-acasandrei

I will work on this and add the changes to the PR

Copy link
Copy Markdown
Contributor Author

@moijes12 moijes12 left a comment

Choose a reason for hiding this comment

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

Thanks @kala-moz

I have added some unit tests for the functionality to select full hash.

For short hash, is there any character length that I need to look at ? From what I see in the commit selection box, the hash has a length of 12 characters. Should I use that ?

Updated `SearchInputAndResults` to:
* Track input value as state
* Check if the input is a hash and if it matches an existing has
* Auto select the hash if it matches the full hash
Added tests for functionality to auto select matched full hash
@kala-moz kala-moz self-requested a review April 15, 2026 21:28
@kala-moz
Copy link
Copy Markdown
Contributor

Thanks @kala-moz

I have added some unit tests for the functionality to select full hash.

For short hash, is there any character length that I need to look at ? From what I see in the commit selection box, the hash has a length of 12 characters. Should I use that ?

@moijes12 No, use the truncateHash helper in src/utils/helper

For example:

  const shortHashMatch = results.find(
        (rev) =>
          truncateHash(rev.revision).toLowerCase() ===
          searchTerm.toLowerCase(),
      );

<Box ref={containerRef}>
<SearchInput
value={inputValue}
onFocus={() => setDisplayDropdown(true)}
Copy link
Copy Markdown
Contributor

@kala-moz kala-moz Apr 15, 2026

Choose a reason for hiding this comment

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

So, we still have the problem of the results drop-down not appearing when the user clicks on the input after pasting the full hash. Also, if the user deletes the selected revision, the results drop-down also doesn't appear when the user clicks the input. Try this to fix the problem and get the full list.

onFocus={() => {
  setDisplayDropdown(true);
  if (!inputValue) {
    void searchRecentRevisions('');
  }
}}

(rev) => rev.id === completeHashMatch.id,
);
if (alreadySelected) {
setDisplayDropdown(false);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Don't set the display to false because that's not the desired behavior after a selection. So please delete this.

return;
}
}
setDisplayDropdown(false);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same here. Delete this please.

Copy link
Copy Markdown
Contributor

@kala-moz kala-moz left a comment

Choose a reason for hiding this comment

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

Hi Alex, thanks for the updates. We still have to work on the behavior because we don't want to hide the drop-down nor clear the input after the hash is pasted and the revision selected. We also need to be able to get the full list of revisions after a selected revision is deleted. I've added some suggestions throughout.

);
if (alreadySelected) {
setDisplayDropdown(false);
setInputValue('');
Copy link
Copy Markdown
Contributor

@kala-moz kala-moz Apr 15, 2026

Choose a reason for hiding this comment

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

Don't clear the input value here either. That's also not the desired behavior

}
}
setDisplayDropdown(false);
setInputValue('');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same here. Please delete.

@moijes12
Copy link
Copy Markdown
Contributor Author

Thanks @kala-moz

This feedback is great. I will work on this and get it done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants