Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Error on Homepage Demo CTA #2474

Merged
merged 1 commit into from
Jul 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Loading