Skip to content

Commit

Permalink
[docs][Autocomplete] Fix GoogleMaps demo
Browse files Browse the repository at this point in the history
  • Loading branch information
hbjORbj committed Dec 20, 2022
1 parent ba0ba65 commit 09842f8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/data/material/components/autocomplete/GoogleMaps.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Grid from '@mui/material/Grid';
import Typography from '@mui/material/Typography';
import parse from 'autosuggest-highlight/parse';
import throttle from 'lodash/throttle';
import { ListItem } from '@mui/material';

// This key was created specifically for the demo in mui.com.
// You need to create a new one for your application.
Expand Down Expand Up @@ -114,6 +115,9 @@ export default function GoogleMaps() {
)}
renderOption={(props, option) => {
const matches = option.structured_formatting.main_text_matched_substrings;
if (!matches) {
return <ListItem sx={{ color: 'text.secondary' }}>No options</ListItem>;
}
const parts = parse(
option.structured_formatting.main_text,
matches.map((match) => [match.offset, match.offset + match.length]),
Expand Down
4 changes: 4 additions & 0 deletions docs/data/material/components/autocomplete/GoogleMaps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Grid from '@mui/material/Grid';
import Typography from '@mui/material/Typography';
import parse from 'autosuggest-highlight/parse';
import throttle from 'lodash/throttle';
import { ListItem } from '@mui/material';

// This key was created specifically for the demo in mui.com.
// You need to create a new one for your application.
Expand Down Expand Up @@ -138,6 +139,9 @@ export default function GoogleMaps() {
)}
renderOption={(props, option) => {
const matches = option.structured_formatting.main_text_matched_substrings;
if (!matches) {
return <ListItem sx={{ color: 'text.secondary' }}>No options</ListItem>;
}
const parts = parse(
option.structured_formatting.main_text,
matches.map((match: any) => [match.offset, match.offset + match.length]),
Expand Down

0 comments on commit 09842f8

Please sign in to comment.