Likert table answer text/description TD cell not rendering HTML

Created on 6 February 2025, 3 months ago

Problem/Motivation

When using a likert table the "Answer text/description" field does not accept HTML, in my case an emoji or Bootstrap icon (see screenshot). This includes the span with .webform-likert-label class.

Steps to reproduce

The likert table "shifts" tables for mobile layouts, so the <thead> is hidden and in the <tbody> > <td> the .webform-likert-label is unhidden to compensate.

  1. Create webform with a likert table and in one of your answers try wrapping the text with <strong></strong> or a Bootstrap icon like <i class="bi bi-emoji-smile"></i>
  2. If you're not seeing anything wrong on your desktop, look at the likert table on your phone and...
  3. ...you should see the HTML you attempted to use rendered as plain text.

Proposed resolution

Allow likert TDs, especially .webform-likert-label to accept HTML.

πŸ› Bug report
Status

Active

Version

6.2

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States yospyn

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @yospyn
  • πŸ‡¨πŸ‡¦Canada Liam Morland Ontario, CA πŸ‡¨πŸ‡¦
  • First commit to issue fork.
  • Pipeline finished with Success
    16 days ago
    Total: 392s
    #474866
  • πŸ‡­πŸ‡·Croatia milosr Croatia, Montenegro

    Hello @yospyn,

    I wouldn't call this a bug, it's more of a feature.

    It was never intended to allow HTML tags inside values.

    However, I've implemented a new function that will permit certain tags:

    strong
    i
    span

    I didn't want to allow all HTML tags for security reasons, so I only permitted these. With them, you can achieve a lot. This should resolve your issue.

    The MR is open, and here's a patch so you can test it.

  • πŸ‡ΊπŸ‡ΈUnited States yospyn

    Hi @milosr tested successfully after upgrading to 6.3@beta from 6.2.9. Now the emoji script renders great within a <span>. Also tested the <i> and <strong> and they also render correctly. Thanks!

  • πŸ‡¨πŸ‡¦Canada Liam Morland Ontario, CA πŸ‡¨πŸ‡¦

    Is there a reason the "Build attributes string" code doesn't use the Drupal Attribute class?

  • πŸ‡­πŸ‡·Croatia milosr Croatia, Montenegro

    Hi @liam morland,

    You're right, I updated the MR.

  • Pipeline finished with Success
    8 days ago
    Total: 468s
    #480983
Production build 0.71.5 2024