Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

254
Vistas
React Google Maps API Autocomplete suggestions are behind the Dialog

I'm using an Autocomplete component from @react-google-maps/api package.

Here is the documentation for the Autocomplete component.

First case:

As we can see in the screenshot below the Autocomplete gives us some suggestions under the input or text field element itself.

enter image description here

But when I wrap the Autocomplete and text field components inside a Dialog component from Material-UI, the suggestions are shown under the Dialog component as we can see in the screenshot below.

enter image description here

Here is the code (note: please insert your Google Maps API key in the index.js file)

dependencies (in package.json file):

"@material-ui/core": "^4.12.3",
"@material-ui/styles": "^4.11.4",
"@react-google-maps/api": "^2.4.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "4.0.3",

Second case:

If we hit enter after inserting some characters to the Autocomplete, the app will crash and print an error autocomplete.getPlaces() is not a function

My questions:

  1. so how can we make the suggestions from the Autocomplete appear directly under the Autocomplete itself (not under the Dialog component)?
  2. how can we fix the error autocomplete.getPlaces() is not a function?
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The dropdown element that displays behind the Dialog has a class name called pac-container (you can see it by inspecting the element). You can set the zIndex of it to a higher number than the Dialog itself to force it appearing in front of the Dialog background:

const useStyles = makeStyles((theme) => ({
  dialog: {
    // the dropdown is next to the dialog root, not inside
    "& + .pac-container": {
      zIndex: theme.zIndex.modal + 1
    }
  }
}));
<Dialog className={classes.dialog}

Codesandbox Demo

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda