Skip to content

Commit

Permalink
remove close callback from popup content
Browse files Browse the repository at this point in the history
  • Loading branch information
matthew44-mappable committed Apr 17, 2024
1 parent 7408207 commit 12f6782
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
10 changes: 3 additions & 7 deletions src/markers/MMapBalloonMarker/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export type MMapBalloonPositionProps =
| `${VerticalPosition} ${HorizontalPosition}`
| `${HorizontalPosition} ${VerticalPosition}`;

export type MMapBalloonContentProps = (close: () => void) => HTMLElement;
export type MMapBalloonContentProps = () => HTMLElement;

export type MMapBalloonMarkerProps = MMapMarkerProps & {
/**
Expand Down Expand Up @@ -91,7 +91,7 @@ export class MMapBalloonMarker extends mappable.MMapComplexEntity<MMapBalloonMar

this._balloonContainer = document.createElement('mappable');
this._balloonContainer.classList.add('mappable--balloon-marker_container');
this._balloonContainer.appendChild(this._props.content(this.__closePopup));
this._balloonContainer.appendChild(this._props.content());

this._balloonTail = document.createElement('mappable');
this._balloonTail.classList.add('mappable--balloon-marker_tail');
Expand Down Expand Up @@ -122,7 +122,7 @@ export class MMapBalloonMarker extends mappable.MMapComplexEntity<MMapBalloonMar

if (propsDiff.content !== undefined) {
this._balloonContainer.innerHTML = '';
this._balloonContainer.appendChild(this._props.content(this.__closePopup));
this._balloonContainer.appendChild(this._props.content());
}

if (propsDiff.show !== undefined) {
Expand Down Expand Up @@ -182,8 +182,4 @@ export class MMapBalloonMarker extends mappable.MMapComplexEntity<MMapBalloonMar
// check right position
this._markerElement.classList.toggle('position-right', horizontalPosition === 'right');
}

private __closePopup = () => {
this._togglePopup(false);
};
}
6 changes: 3 additions & 3 deletions src/markers/MMapDefaultPopupMarker/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class MMapDefaultPopupMarker extends mappable.MMapComplexEntity<MMapDefau
const isActionChange = oldProps.action !== action;

if (isTitleChange || isDescriptionChange || isActionChange) {
this._balloon.update({content: (close) => this.__createDefaultPopup(close)});
this._balloon.update({content: () => this.__createDefaultPopup()});
}

this._balloon.update(this._props);
Expand All @@ -76,7 +76,7 @@ export class MMapDefaultPopupMarker extends mappable.MMapComplexEntity<MMapDefau
this._element.classList.toggle('mappable--default-popup__dark', themeCtx.theme === 'dark');
}

private __createDefaultPopup: MMapBalloonContentProps = (close) => {
private __createDefaultPopup: MMapBalloonContentProps = () => {
const {title, description, action} = this._props;
this._element = document.createElement('mappable');
this._element.classList.add('mappable--default-popup');
Expand All @@ -95,7 +95,7 @@ export class MMapDefaultPopupMarker extends mappable.MMapComplexEntity<MMapDefau
const closeButton = document.createElement('button');
closeButton.classList.add('mappable--default-popup_header_close');
closeButton.innerHTML = closeSVG;
closeButton.addEventListener('click', () => close());
closeButton.addEventListener('click', () => this._balloon.update({show: false}));
popupHeaderElement.appendChild(closeButton);

if (description) {
Expand Down

0 comments on commit 12f6782

Please sign in to comment.