-
-
Notifications
You must be signed in to change notification settings - Fork 855
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
Rebuild rows when predefined places change #539
Conversation
Fixes #495 |
@guilhermepontes this seems like a pretty common issue. Any chance we can merge in the near term? |
Curious to know the use case behind this. Would you mind giving me some background on this? |
@@ -348,7 +354,7 @@ export default class GooglePlacesAutocomplete extends Component { | |||
} | |||
|
|||
_getPredefinedPlace = (rowData) => { | |||
if (rowData.isPredefinedPlace !== true) { | |||
if (rowData.isPredefinedPlace !== true || rowData.description == null) { |
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.
I thought about this a bit. I think we might be better off filtering out the predefined places where the description is null or length === 0. If the description is blank, there is still a space (that was pressable) in the list.
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.
I would add res = [ ...this.props.predefinedPlaces.filter( (place) => place.description && place.description.length, ), ];
in line 101, or something similar. It doesn't look like I can edit this PR, so let me know what you think about this and let's get this merged in.
@freeatnet can you address the comments above? Would like to get this merged. |
@bell-steven I'm not sure I understand the logic of the changes you suggested. The patch I provided is a solution to the specific issue I was facing; if I were to implement this from scratch, I'd probably try to get rid of the description-matching logic of |
@freeatnet the logic behind my change was to solve the problem you were facing, while making the behavior of the library consistent.
You mentioned that this was the specific issue your were solving with that line of code. When I tested it, I found that there would still be a blank row rendered in the list if the description was not set (and if there are a few blank rows, because they have a separating line between them, things get a little wonky). Even if I were to remove the matching logic in I will note, there are plenty of parts of this library which can be simplified or stripped out. But, because there are so many little features, changes can have some nasty side effects. The goal is, over time, to try and simplify things here, but it doesn't happen overnight. See #552 for more. |
Thanks for the PR! Closed with 31f98b4 |
This PR adds
componentDidUpdate
handler that will update the data source when the list ofpredefinedPlaces
changes.