googlemaps / googlemaps/extended-component-library

Expose onClear event for Place Autocomplete Element

Open
#275 1 comment 6 reactions 0 assignees View on GitHub
triage me type: feature request
Dominant language
TypeScript
Stars
192
Forks
22
Avg merge
2d 23h
Merged PRs (30d)
8

Description

**Is your feature request related to a problem? Please describe.**
I added the PlaceAutocompleteElement to a map, and when I select a location I also add a pin.
When I clear the input, I’d like to remove that pin as well. However, there’s currently no way to detect when the built-in clear (“X”) button is pressed.
Since the button lives inside a closed shadow root, developers can’t attach their own event listeners as a workaround.

**Describe the solution you'd like**
Expose a new event (e.g., clear, input-clear, etc.) that fires whenever the clear button is clicked.
Alternatively, allow developers to pass a handler or listen to an existing DOM event for this action.

**Describe alternatives you've considered**
None

**Additional context**
Just like there’s a gmp-select event when a place is chosen, it would be very convenient to also have a corresponding clear event for when the input is reset.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.