question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

detachedMediaQuery doesn't persist setQuery in the search bar input

See original GitHub issue

Description

In a React implementation of autocomplete, when setting the query in an item’s onSelect, it does not persist in the search bar input’s value when you have detachedMediaQuery always on (detachedMediaQuery: '').

Reproduction

https://codesandbox.io/s/react-algolia-autocomplete-2-u9wqv?file=/src/App.js

Steps

  1. Click on the search bar
  2. Scroll to the “Can’t find what you’re looking for?” section at the bottom
  3. Click one of the query suggestions, like ‘macbook’
  4. Scroll back up to see the search bar input. The search bar input should be blank.

Expected behavior

The value in the search bar input should persist when updating the query via setQuery in an onSelect, even if detached mode is on.

Environment

  • OS: macOS
  • Browser: Chrome, Safari, Firefox
  • Autocomplete version: 1.1.0

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

7reactions
francoischalifourcommented, Jul 26, 2021

Yeah, it should fill the query with the item’s value. We’ll investigate why this happens. Thanks again.

0reactions
chuckmeyercommented, Nov 7, 2022

This issue exists with the code Algolia supplies alongside this blog post: https://www.algolia.com/blog/ux/replicating-the-algolia-documentation-search-with-autocomplete/

The code only works because it is pinned to a specific commit (https://codesandbox.io/s/algoliaautocomplete-example-preview-panel-in-modal-zhhp8?file=/app.tsx)

It will not work with modern/official releases of Autocomplete due to the above issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Searchbar not responding properly to media query
I added a searchbar, which messed up the display of the cart button, but I seemingly fixed it's display issue with a negative...
Read more >
AutoComplete Search Box Not Holding Query Value in Mobile ...
I've finally found the issue. Autocomplete has a property “detachedMediaQuery”, which by default is turned on, however the documentation doesn't ...
Read more >
Beginner's guide to media queries - Learn web development
Beginner's guide to media queries ... The CSS Media Query gives you a way to apply CSS only when the browser and device...
Read more >
CSS Media Min-Width & Max-Width Queries - How They Work
So if the email is opened on an iPhone 5S with a screen width of 320px, the media query will trigger and all...
Read more >
A Complete Guide to CSS Media Queries
Anatomy of a Media Query. Now that we've seen several examples of where media queries can be used, let's pick them apart and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found