processwire / processwire-issues

ProcessWire issue reports.
45 stars 2 forks source link

Support for specifying a background color for repeater items leads to unwanted results #1716

Closed processwired closed 1 year ago

processwired commented 1 year ago

Short description of the issue

In some cases the support for specifying a background color for Repeater items leads to unexpected results. (Frankly, I think the current implementation is a bit unfortunate, as all other Repeater options are explicitly set via a configuration in the backend. This background color feature is a different animal – it's more of a convention.And I had to dig to find some kind of documentation for it - here).

The feature was introduced here.

Expected behavior

If a field contains a string that has a syntax of a hex color, it does not necessarily have to be a color :)

Actual behavior

If you specify a field, let's say a {title} field for example, in "Repeater item labels", and if this title filed contains a text like "Item #400", the repeater gets a brown background color. (Unfortunately, "#400" is part of a product name here and can't be replaced by "No. 400" or something).

Optional: Suggestion for a possible fix

Provide a more specific regex or it should be possible to disable the option. I think it is error prone to interpret the contents of a field and use it for configuration. The color should be better set by an option outside the brackets.

Steps to reproduce the issue

  1. Create a simple Repeater with a title field and enter "{title}" in "Repeater item labels"
  2. Enter a title like "Item #400"
  3. Save. The Repeater gets a brown background, which is an unintended.

Setup/Environment

ryancramerdesign commented 1 year ago

Thanks @processwired I've pushed a fix for this. I'll make the same adjustment to RepeaterMatrix.

matjazpotocnik commented 1 year ago

@processwired, can this be closed?

matjazpotocnik commented 1 year ago

@processwired Closing on the assumption this is fixed. Please comment here again if that is not the case.