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(atomic, quantic): broken HTML because of formatting in CRGA markdown heading #4553

Closed
wants to merge 4 commits into from

Conversation

lbergeron
Copy link
Contributor

@lbergeron lbergeron commented Oct 17, 2024

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 the custom Marked renderer. 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>

Copy link

Pull Request Report

PR Title

✅ Title follows the conventional commit spec.

Live demo links

Bundle Size

File Old (kb) New (kb) Change (%)
case-assist 244.5 244.5 0
commerce 343.1 343.1 0
search 417.2 417.2 0
insight 395 395 0
product-listing 306.8 306.8 0
product-recommendation 215.3 215.3 0
recommendation 257.7 257.7 0
ssr 407.7 407.7 0
ssr-commerce 353.7 353.7 0

SSR Progress

Use case SSR (#) CSR (#) Progress (%)
search 39 44 89
recommendation 0 4 0
product-recommendation 0 10 0
product-listing 0 13 0
case-assist 0 6 0
insight 0 27 0
commerce 0 15 0
Detailed logs search : buildInteractiveResult
search : buildInteractiveInstantResult
search : buildInteractiveRecentResult
search : buildInteractiveCitation
search : buildGeneratedAnswer
recommendation : missing SSR support
product-recommendation : missing SSR support
product-listing : missing SSR support
case-assist : missing SSR support
insight : missing SSR support
commerce : missing SSR support

);
});

it('should transform heading with nested formatting', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we also have this test for nested formatting in the quantic tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Considering the test suite was simplified for Quantic, I went with a single test to cover the change. I don't think adding another test for nested formatting is necessary.

Copy link
Contributor

@alexprudhomme alexprudhomme left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, because of the incident that occured last thursday/friday with the v2 release. It wrongfully updated the versions of all package.json in the ui-kit publish commit. We removed that commit after this PR pulled it. Can you revert those changes ?

@lbergeron
Copy link
Contributor Author

Creating a clean PR with the TIP of v2. See #4564

@lbergeron lbergeron closed this Oct 21, 2024
@lbergeron lbergeron deleted the fix/SVCC-4245-backport-v2 branch October 21, 2024 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants