Skip to content

Commit

Permalink
Fix ignore props.popup.content in Vue MMapDefaultMarker (#32)
Browse files Browse the repository at this point in the history
<!--

Thank you for submitting a pull request!

Here's a checklist you might find useful.
[ ] There is an associated issue that is labelled
  'Bug' or 'help wanted' or is in the Community milestone
[ ] Code is up-to-date with the `main` branch
[ ] You've successfully run `npm test` locally
[ ] There are new or updated tests validating the change

-->

Fixes #31
  • Loading branch information
matthew44-mappable authored Aug 29, 2024
1 parent 45b5196 commit 74f3e71
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/markers/MMapDefaultMarker/vue/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,22 @@ export const MMapDefaultMarkerVuefyOverride: CustomVuefyFn<MMapDefaultMarker> =
props,
slots: Object as TVue.SlotsType<MMapDefaultMarkerSlots>,
setup(props, {slots, expose}) {
const content: TVue.Ref<TVue.VNodeChild | null> = Vue.ref(null);
const content: TVue.Ref<TVue.VNodeChild | string | null> = Vue.ref(null);
const popupHTMLElement = document.createElement('mappable');

const markerRef = Vue.ref<{entity: MMapDefaultMarker} | null>(null);
const markerEntity = Vue.computed(() => markerRef.value?.entity);

const popup = Vue.computed<MMapDefaultMarkerProps['popup']>(() => {
if (slots.popupContent === undefined) {
if (slots.popupContent === undefined && props.popup?.content === undefined) {
return undefined;
}
content.value = slots.popupContent();

if (typeof props.popup?.content === 'string') {
content.value = props.popup.content;
} else {
content.value = slots.popupContent?.();
}
return {...props.popup, content: () => popupHTMLElement};
});
expose({entity: markerEntity});
Expand Down

0 comments on commit 74f3e71

Please sign in to comment.