这是indexloc提供的服务,不要输入任何密码
Skip to content

google.maps.places.Autocomplete: suggestion box position is absolute to <body> instead of <input> #186

@Juneezee

Description

@Juneezee

Environment details

  1. Specify the API at the beginning of the title (for example, "Places: ...")

    const {Autocomplete} = await APILoader.importLibrary('places', this) as
    typeof google.maps.places;
    const autocomplete =
    new Autocomplete(inputElement, await this.makeAutocompleteOptions());

  2. OS type and version: Linux 6.7.9

  3. Library version: 0.6.7

Steps to reproduce

  1. Use <PlacePicker> in a page with vertical overflow content (i.e. `overflow-y: "scroll")
  2. Search something
  3. Scroll the page down
  4. The dropdown suggestion box is positioned relative to <body> instead of the search bar <input>

Demo:

2024-03-13.21-43-15.mp4

Code example

Minimal reproducible code in React

import * as GMPX from '@googlemaps/extended-component-library/react';
import React from 'react';

const API_KEY = process.env.REACT_APP_MAPS_API_KEY;

export default class App extends React.Component {
  render() {
    return (
      <div style={{ 
        position: "fixed", 
        inset: 0, 
        padding: "20px",
        overflowY: "scroll",
      }}>
        <GMPX.APILoader apiKey={API_KEY} />

        <div style={{ height: "300px" }}></div>

        <GMPX.PlacePicker />

        <div style={{ height: "1300px" }}></div>
      </div>
    );
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions