react-google-maps-api icon indicating copy to clipboard operation
react-google-maps-api copied to clipboard

onCloseClick not fired on InfoBoxComponent

Open Saad-Khurshid opened this issue 2 years ago • 6 comments

InfoBox OnCloseClick stopped working when version updated from ^2.7.0 to 2.12.0

I was able to make it work. Adding this here so that if anybody else faces the issue can be helped.

os: mac node version 12.22.7 react version 16.13.1 @babel version ^7.12.1

@react-google-maps/api version

Q) How does it behave? A) I tried all possibilities to make onCloseClick work using 1. onCloseClick listener 2. using onLoad to add these properties i.e. infoBox.closeListener, infobox.addClickHandler() and verified using infoBox.getCloseClickHandler()

Solution

The only way for me to fix this issue was by downgrading to version "2.7.0"

Saad-Khurshid avatar Jun 30 '22 20:06 Saad-Khurshid

@Saad-Khurshid use InfoBoxF instead

JustFly1984 avatar Jul 15 '22 16:07 JustFly1984

@Saad-Khurshid use InfoBoxF instead

It doesn't help

https://codesandbox.io/s/interesting-hill-09v5m5?file=/src/App.js

aso1datov avatar Dec 15 '22 15:12 aso1datov

@aso1datov use this in you package.json "@react-google-maps/api": "2.7.0", and then use it like below {infoWindow && <InfoBox onCloseClick={() => setInfoWindow(null)} > </InfoBox>

Saad-Khurshid avatar Dec 17 '22 19:12 Saad-Khurshid

@JustFly1984 I can not give this a try at this time.

Saad-Khurshid avatar Dec 17 '22 19:12 Saad-Khurshid

@aso1datov use this in you package.json "@react-google-maps/api": "2.7.0", and then use it like below {infoWindow && <InfoBox onCloseClick={() => setInfoWindow(null)} > </InfoBox>

I use a different approach:

const infoBoxOptions =  {
  position,
  disableAutoPan: true,
  isHidden: !showInfoBox,
  visible: showInfoBox,
}

return (
  <InfoBoxF options={infoBoxOptions}>
  // my content with custom close button
  </InfoBoxF>
)

aso1datov avatar Dec 19 '22 05:12 aso1datov

The issue is still present in Dec 2023. InfoBoxF and InfoBox still can't close with the close button.

james10424 avatar Dec 13 '23 00:12 james10424