Skip to content

Commit

Permalink
Fixed key index issue with search results
Browse files Browse the repository at this point in the history
  • Loading branch information
jmbarne3 committed Aug 23, 2024
1 parent 0cf6043 commit 2a20e8d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ function App() {
const retval: Array<Feature> = [];

if (!searchQuery) {
setSearchResults(retval);
setSearchResults([]);
setSearchResultData({
type: 'FeatureCollection',
features: []
Expand All @@ -229,7 +229,7 @@ function App() {
}

if (buildingPointData) {
let locationResults = buildingPointData.features.filter((e: any) => {
const locationResults = buildingPointData.features.filter((e: any) => {
const includesName = e!.properties!.Name.toLowerCase().includes(searchQuery.toLowerCase());
const includesAbbr = e!.properties!.Abbrev.toLowerCase() === searchQuery.toLowerCase();
const includesBldgNum = e!.properties!.BldgNum.toLowerCase() === searchQuery.toLowerCase();
Expand All @@ -243,10 +243,10 @@ function App() {
clearVisibility();
}

setSearchResults(retval);
setSearchResults([...retval]);
setSearchResultData({
type: 'FeatureCollection',
features: retval
features: [...retval]
});
};

Expand Down
2 changes: 1 addition & 1 deletion src/components/SearchResults.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export default function SearchResults(props: SearchResultsProps) {
<ul role="listbox" tabIndex={-1} id='search-results' className='search-results'>
{props.searchResults.map((result: Feature) => {
return (
<li key={result!.properties!.Name} className='list-item search-result'>
<li key={`${result!.properties!.Name}_${result!.properties!.BldgNum}`} className='list-item search-result'>
<a
className='search-result-link'
onClick={() => {
Expand Down

0 comments on commit 2a20e8d

Please sign in to comment.