Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show autocomplete results when you change the search type #10359

Open
1 task
RayBB opened this issue Jan 18, 2025 · 7 comments
Open
1 task

Show autocomplete results when you change the search type #10359

RayBB opened this issue Jan 18, 2025 · 7 comments
Labels
Lead: @RayBB Issues overseen by Ray (Onboarding & Documentation Lead) [manages] Needs: Breakdown This big issue needs a checklist or subissues to describe a breakdown of work. [managed] Needs: Response Issues which require feedback from lead Priority: 3 Issues that we can consider at our leisure. [managed] Type: Bug Something isn't working. [managed]

Comments

@RayBB
Copy link
Collaborator

RayBB commented Jan 18, 2025

Problem

Right now if you change the search type at the top of OL from something like "title" to "author" we don't show the results right away, you have to click the text box before the results show. It would be great if we showed the results right away.
See video (with audio) for example.

search.mp4

Reproducing the bug

  1. Go to openlibrary.org
  2. Type in a query (don't hit enter)
  3. Select another search type (like author)
  4. Results won't show
  • Expected behavior: Shows results
  • Actual behavior: Doesn't show results

Context

  • Browser (Chrome, Safari, Firefox, etc):
  • OS (Windows, Mac, etc):
  • Logged in (Y/N):
  • Environment (prod, dev, local): prod

Breakdown

Requirements Checklist

  • When you change the search type the results show right away

Related files

Stakeholders


Instructions for Contributors

  • Please run these commands to ensure your repository is up to date before creating a new branch to work on this issue and each time after pushing code to Github, because the pre-commit bot may add commits to your PRs upstream.
@RayBB RayBB added Needs: Breakdown This big issue needs a checklist or subissues to describe a breakdown of work. [managed] Needs: Lead Needs: Triage This issue needs triage. The team needs to decide who should own it, what to do, by when. [managed] Type: Bug Something isn't working. [managed] labels Jan 18, 2025
@SharkyBytes
Copy link
Contributor

Hi @RayBB

Ah, great finding! I was actually experiencing this issue before, and it would be awesome to see it resolved. Is it possible for me to get assigned to this issue? I'd love to work on it. Looking forward to your response!

@RayBB
Copy link
Collaborator Author

RayBB commented Jan 18, 2025

@SharkyBytes yes go for it 👍
Let me know if you have questions

@mekarpeles
Copy link
Member

mekarpeles commented Jan 19, 2025

Moving forward, as a matter of team policy, I'd like if staff have a chance to review and triage issues prior to assignment (re: project management notes). Sorry for the cases where this may cause a bit of lag time. Also, apologies as I know not all our docs are easily discoverable yet!

@SharkyBytes I'm also noticing you're currently assigned to 4 issues now that have no PR's associated so if possible i'd love us to followup or drop some of those issues before pushing forward with another!
https://github.com/internetarchive/openlibrary/issues?q=is%3Aissue%20state%3Aopen%20assignee%3ASharkyBytes

Thank you both :)

@mekarpeles mekarpeles added Priority: 3 Issues that we can consider at our leisure. [managed] Lead: @RayBB Issues overseen by Ray (Onboarding & Documentation Lead) [manages] and removed Needs: Triage This issue needs triage. The team needs to decide who should own it, what to do, by when. [managed] labels Jan 19, 2025
@RayBB
Copy link
Collaborator Author

RayBB commented Jan 23, 2025

@mekarpeles is this issue considered triaged?

@Spaarsh
Copy link
Contributor

Spaarsh commented Jan 24, 2025

@RayBB I think I have figured this out. Turns out, the current change handler for the autocomplete was triggered if the search bar was in focus. I changed the code to trigger the autocomplete whenever the facet is changed.

Here is the current code:

handleFacetValueChange(newFacet) {
// update the UI
this.$facetSelect.val(newFacet);
const text = this.$facetSelect.find('option:selected').text();
$('header#header-bar .search-facet-value').html(text);
// Get new results
if (this.$input.is(':focus')) {
this.renderAutocompletionResults();
}
}

And I changed it to this:

handleFacetValueChange(newFacet) {
        // update the UI
        this.$facetSelect.val(newFacet);
        const text = this.$facetSelect.find('option:selected').text();
        $('header#header-bar .search-facet-value').html(text);

        // Add immediate refresh when input has value
        if (this.$input.val()) {
            this.renderAutocompletionResults();
        }
    }

Here's the demo:

autocomplete-demo.webm

Thanks!

@RayBB
Copy link
Collaborator Author

RayBB commented Jan 24, 2025

I'm still waiting for @mekarpeles to confirm if this this triaged or not.

Your solution seems like a good start to me though. Is it change any other behavior like when you click on another part of the page or move focus away with tab? We'll want that functionality to remain the same.

@Spaarsh
Copy link
Contributor

Spaarsh commented Jan 25, 2025

@RayBB yes that thing is intact.

I've simple changed the handler that handles a change in the facet, nothing else.

@github-actions github-actions bot added the Needs: Response Issues which require feedback from lead label Jan 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Lead: @RayBB Issues overseen by Ray (Onboarding & Documentation Lead) [manages] Needs: Breakdown This big issue needs a checklist or subissues to describe a breakdown of work. [managed] Needs: Response Issues which require feedback from lead Priority: 3 Issues that we can consider at our leisure. [managed] Type: Bug Something isn't working. [managed]
Projects
None yet
Development

No branches or pull requests

5 participants