Skip to content

Commit

Permalink
fix: Error on Homepage Demo CTA
Browse files Browse the repository at this point in the history
  • Loading branch information
japhethLG committed Jul 12, 2024
1 parent 22d8f34 commit 6496acd
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
25 changes: 24 additions & 1 deletion src/views/zesty/Article.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,26 @@ function Article({ content }) {
// Define a regular expression pattern to match [_CTA_]
let regexPattern = /\[CALL TO ACTION (\d+)\]/g;

useEffect(() => {
const removeSpansInHeadings = (html) => {
let tempDiv = document.createElement('div');
tempDiv.innerHTML = html;

let headings = tempDiv.querySelectorAll('h1, h2, h3, h4, h5, h6');

headings.forEach((heading) => {
let spans = heading.querySelectorAll('span');
spans.forEach((span) => {
span.replaceWith(...span.childNodes);
});
});

return tempDiv.innerHTML;
};

setNewContent(removeSpansInHeadings(newContent));
}, [newContent]);

useEffect(() => {
const validateWysiwyg = () => {
if (newContent?.includes('Error hydrating')) {
Expand Down Expand Up @@ -209,7 +229,10 @@ function Article({ content }) {
? `:is(span, p, h1, h2, h3, h4, h5, h6) :is(img) {
width: auto;
max-width: 100%;
}`
}
:h1 span, :h2 span {
color: black;
}`
: ``;

// Match CTA component sort order id from array to return its props
Expand Down
4 changes: 2 additions & 2 deletions src/views/zesty/Homepage/EnterpriseGrowth.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ const Child = dynamic(() => import('revamp/ui/EnterpriseGrowth'), {
loading: Placeholder,
});

const Index = () => {
const Index = (props) => {
const { ref, inView } = useInView({
triggerOnce: true,
threshold: 0,
});
return <div ref={ref}>{inView && <Child />}</div>;
return <div ref={ref}>{inView && <Child {...props} />}</div>;
};

export default Index;

0 comments on commit 6496acd

Please sign in to comment.