detachedMediaQuery doesn't persist setQuery in the search bar input
See original GitHub issueDescription
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
- Click on the search bar
- Scroll to the “Can’t find what you’re looking for?” section at the bottom
- Click one of the query suggestions, like ‘macbook’
- 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:
- Created 2 years ago
- Comments:9 (3 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yeah, it should fill the query with the item’s value. We’ll investigate why this happens. Thanks again.
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.