Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…#15) * Fix: Don't set height on suggestions container (fixes #13) This commit changes the styling of the suggestions container so that it no longer has a set height of 200 units. This caused the suggestions container to take up space when the suggestions container wasn't rendered. This commit fixes bug: #13 modified: src/MUIPlacesAutocomplete.jsx * Fix: Render suggestions container over target (fixes #14) This commit changes the behavior of how we render our suggestions container. In the past I naively believed that when our suggestions container was rendered it would magically "hide" elements that came after it. As I'm learning this isn't the case. As a result of my inexperience the suggestions container would "blend" with elements of the same "depth". This is all documented in bug #14. We now render the suggestions container over a target provided to us. We now get the desired behavior where the suggestions container renders over elements and properly receives all of the focus/events. While fixing how we rendered the suggestions container though I took a big departure from how I was doing things in the past. In the past I used the 'react-autosuggest' to provide autocomplete functionality to our component. When trying to use it to properly render our suggestions container (i.e. render over/popover a target) I found it increasingly difficult to work with. As a result I looked for other solutions and decided to use 'downshift'. 'downshift' was a lot easier to work with and "did more" for me out of the box. I want to make clear for anyone who may read this in the future that the 'react-autosuggest' package is great and people ought to look into using it to meet their needs. If I were more technically adept then I may have been able to make 'react-autosuggest' work. In conjunction with 'downshift' we also use 'react-popper' which is a React wrapper around PopperJS to provide the popover (modal) functionality of our suggestions container. This commit fixes bug: #14 modified: package.json modified: src/MUIPlacesAutocomplete.jsx modified: src/index.js modified: test/setup-dom.js modified: test/test.jsx modified: test/test.jsx.snap modified: yarn.lock * Docs: Link to my (Chris') MIT license This commit modifies the license section of the README to link to my MIT license hosted at https://mit-license.org/ (via https://github.com/remy/mit-license). modified: README.md * Chore: Add test coverage to verify rendered suggestions are unique This commit adds test coverage to verify that non-unique predictions returned by the Google Maps Autocomplete Service are rendered as unique suggestions. We refactored the code some by moving the logic of creating a list of unique suggestions out of the 'onInputValueChange()' method into the 'renderSuggestionsContainer()' method. I did this as it allows for more clear testing of ideas. While adding test coverage I was conflating the issues of having predictions returned async/React setting state async and having all rendered suggestions be unique. This caused me to try some weird testing patterns where I was waiting for the async React state setting to complete and then verify my suggestions. It seems doing this is less performant/optimized but maybe I was being premature in that regard and this is going to lead to better debugging/maintenance. modified: src/MUIPlacesAutocomplete.jsx modified: test/test.jsx modified: test/test.jsx.snap * Docs: Update README to show 'renderTarget' prop usage This commit updates the README to show how to use the 'renderTarget' prop as it is required. The 'renderTarget' prop takes a function which renders components/elements that the rendered suggestions list ought to popover. modified: README.md * Chore: Update demo to make use of 'renderTarget' prop Commit e40dbec added a new library named 'react-popper' (wrapper around PopperJS) to help us render over/popover the list of suggestions over a component/element. It also added a prop to the <MUIPlacesAutocomplete> component named 'renderTarget' that renders said components/elements to render the list of suggestions over. This commit updates the demo to make use of the newly required 'renderTarget' prop. We simply provided a self-closing <div> which is unexciting. In the future maybe we can invest sometime in the demo to provide something like a form for providing address information that autofills when a suggestion is selected. modified: demo/Demo.jsx * Docs: Remove erroneous chars in entry in table under Usage->Props Remove erroneous '[]' chars around the 'renderTarget' entry in the table that describes the props on the <MUIPlacesAutocomplete> component. modified: README.md
- Loading branch information