charlie-tango / react-umbraco

React components for working with Umbraco Headless
MIT License
5 stars 1 forks source link

"path" attribute is not present #7

Closed barbararcbf12 closed 2 months ago

barbararcbf12 commented 2 months ago

https://github.com/charlie-tango/react-umbraco/blob/e087ecf6b9ca17d1f43674c9b25ba806a5b3f567/src/UmbracoRichText.tsx#L211

@thebuilder and @fbosch , when using the in Diversa, I've noticed that the value of the href attributes related to the a tags we receive inside of the Richtext elements is coming as "undefined". Therefore, the anchor tag is added to the HTML but the href isn't (see image below). image

When debugging the UmbracoRichText component, I've noticed that it is happening because of the assignment done in the part of the code linked above. It seems like in the content we receive from Umbraco, the path attribute is never present. So, I suggest that we either remove this passage of the code OR we add a check as below.

   if(element.tag === "a" && route?.path) {
        attributes.href = route?.path;
    }