Skip to content

Commit

Permalink
fix: Error on Homepage Demo CTA (#2474)
Browse files Browse the repository at this point in the history
# Description

Fix wrong props of homepage cta; Removed spans in headings for articles

Fixes #2472, #2473

## Type of change

Please delete options that are not relevant.

- [x] Bug fix (non-breaking change which fixes an issue)

# How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide
instructions so we can reproduce.

- [x] Manual Test

# Screenshots / Screen recording
Before:

![image](https://github.com/user-attachments/assets/ef1994f5-81ee-42cd-b185-a4d166c27417)

![image](https://github.com/user-attachments/assets/f49dd7ff-8872-4adf-a1c7-b866c280a9e2)

After:

![image](https://github.com/user-attachments/assets/416038be-33cd-4e60-8a58-1ec2a37fa71d)

![image](https://github.com/user-attachments/assets/0c761b0e-a65c-46cc-aeec-66182d8f5ae3)
  • Loading branch information
japhethLG committed Nov 22, 2024
1 parent cdbf96b commit 79e5af1
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 79e5af1

Please sign in to comment.