Skip to content

Commit

Permalink
fix(cms-base): prevent displaying empty elements (NTR)
Browse files Browse the repository at this point in the history
  • Loading branch information
mkucmus authored and patzick committed Feb 20, 2023
1 parent 75877f9 commit da2f689
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/poor-laws-bathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@shopware-pwa/cms-base": patch
---

Prevent displaying not mapped texts & images elements with no URL
5 changes: 5 additions & 0 deletions .changeset/soft-seahorses-mate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@shopware-pwa/composables-next": patch
---

Prevent using mapped field configurations directly
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const {
<template>
<!-- TODO: using a tag only works with externalLink, need to improve this element to deal with both internalLink & externalLink -->
<component
v-if="imageAttrs.src"
class="cms-element-image relative"
:is="imageLink.url ? 'a' : 'div'"
:style="containerStyle"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const CmsTextRender = () => {
},
},
};
const rawHtml = mappedContent.value || "<div></div>";
const rawHtml = mappedContent.value?.length > 0 ? mappedContent.value : "<div></div>";
return renderHtml(rawHtml, config, h, context);
};
</script>
Expand Down
4 changes: 3 additions & 1 deletion packages/composables/src/cms/useCmsElementConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ export function useCmsElementConfig<
const getConfigValue = <ELEMENT_CONFIG extends keyof T["config"]>(
key: ELEMENT_CONFIG
): typeof element.config[ELEMENT_CONFIG]["value"] => {
return element.config[key]?.value;
return (
element.config[key]?.source !== "mapped" && element.config[key]?.value
);
};

return {
Expand Down

0 comments on commit da2f689

Please sign in to comment.