-
Notifications
You must be signed in to change notification settings - Fork 557
feat(autocomplete): add responsive detached mode #6898
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
base: master
Are you sure you want to change the base?
Conversation
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 3280367:
|
28362c5 to
daac09d
Compare
377d239 to
8f597ab
Compare
packages/react-instantsearch/src/widgets/__tests__/Autocomplete.test.tsx
Show resolved
Hide resolved
Haroenv
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks great, thanks!
| const [isModalOpen, setIsModalOpen] = useState(false); | ||
| const [isModalDetached, setIsModalDetached] = useState(false); | ||
|
|
||
| useEffect(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could these useEffect's be done in the ui-components? We already have the hook being passed to them (via the prop getter function I believe)
Summary
This PR adds a responsive detached mode to the Autocomplete widget for mobile devices. When a configurable media query matches (default:
max-width: 680px), the inline search input is replaced with a search button that opens a full-screen overlay with the search form and results panel.detachedMediaQueryoption to control when detached mode activates (set to""to disable)translationsoption for detached mode UI text (cancel button, search button title, clear button title)AutocompleteDetachedSearchButton,AutocompleteDetachedOverlay,AutocompleteDetachedContainer,AutocompleteDetachedFormContainerAutocompleteSearch(React) to accept props directly instead of usinguseSearchBoxinternally9998, Autocomplete10000)react/query-suggestionsexample with mobile-responsive layoutResult
Verified with the
react/query-suggestionsexample (yarn startinexamples/react/query-suggestions):detachedMediaQuery="": Completely disables detached mode.All common widget tests pass for both
instantsearch.jsandreact-instantsearch.