jss icon indicating copy to clipboard operation
jss copied to clipboard

Text field with empty value omits html props

Open ahiyalala opened this issue 11 months ago • 2 comments

Describe the Bug

When a <Text /> field has an empty value, the styling that was intended for this element was omitted because the htmlProps were not applied to the DefaultEmptyFieldEditingComponentText whose rendering was only return <span>[No text in field]</span>

To Reproduce

Create a styling for the text element, for example:

.bg-red {
 background-color: red;
}

Apply CSS class in the <Text /> component:

<Text tag="p" className="bg-red" field={props.field.TextField} />

Where props.field.TextField is a Field<string> and is empty.

Here's a real life example, where the field Secondary Topic is empty in one, and populated on another Image

Expected Behavior

Styling should still appear even if the text field has an empty value.

Possible Fix

Ensure DefaultEmptyFieldEditingComponentText component would still apply the htmlProps

Provide environment information

  • Sitecore Version: XM Cloud
  • JSS Version: 22.1.4
  • Browser Name and version: Edge/Chromium
  • Operating System and version (desktop or mobile): Windows 11
  • Link to your project (if available): N/A

ahiyalala avatar Jan 17 '25 06:01 ahiyalala

Thanks @ahiyalala for a clear scenario. I've added this to our team's backlog.

art-alexeyenko avatar Jan 28 '25 23:01 art-alexeyenko

Thanks @art-alexeyenko for acknowledging the issue. I discovered that a Pull Request #2001 has already been made that could resolve this issue, maybe this can be given attention?

ahiyalala avatar Feb 07 '25 12:02 ahiyalala

Resolved in #2141

illiakovalenko avatar Sep 05 '25 08:09 illiakovalenko