-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(atomic): broken HTML because of formatting in CRGA markdown headi…
…ng (#4522) [SVCC-4245](https://coveord.atlassian.net/browse/SVCC-4245) A CRGA model generally generates markdown headings like this: ``` # Title ``` However, in some cases, it can generate headings this way: ``` **Title** ===== ``` When it does, the HTML returned by the `generated-answer` component is broken and the heading reads like this: ``` Title>Title ``` The core of the issue is in [this custom Marked renderer](https://github.com/coveo/ui-kit/blob/master/packages/atomic/src/components/common/generated-answer/generated-content/markdown-utils.ts#L50). When the heading has formatting, the `text` parameter contains the HTML rendering of the heading content. Inserting non-escaped HTML into the `aria-label` attribute then breaks the `div` element. This PR fixes the issue by affecting only the heading text content to the `aria-label` attribute. To do so, the HTML elements are removed from the heading content when setting `aria-label`. The heading content HTML is kept intact when setting the heading inner HTML though in order to keep the heading formatting. For example: ``` **Title** ===== ``` Would generate this HTML ``` <div part="answer-heading-1" aria-label="Title"> <strong part="answer-strong">Title</strong> </div> ``` [SVCC-4245]: https://coveord.atlassian.net/browse/SVCC-4245?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
- Loading branch information
Showing
4 changed files
with
53 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters