Overview

This is a minor thing and not a blocker as it can be worked around.

If you have a prop like:

     level:
       type: string
       title: Level
       description: 'Semantic level: 1, 2, 3, 4, 5, 6.'
       default: '2'
       enum:
        - '1'
        - '2'
        - '3'
        - '4'
        - '5'
        - '6'
       examples:
        - '2'

then you get this error when trying to change the prop in the sidebar prop form:

Drupal\Core\Render\Component\Exception\InvalidComponentException: [level] Integer value found, but a string or an object is required/n[level] Does not have a value in the enumeration ["1","2","3","4","5","6"] in Drupal\Core\Theme\Component\ComponentValidator->validateProps() (line 203 of /var/www/html/web/core/lib/Drupal/Core/Theme/Component/ComponentValidator.php).

Proposed resolution

Decide if we should allow integers masquerading as strings. If so, handle accordingly.

User interface changes

Sidebar form will let you change the prop value.

Comments

kristen pol created an issue. See original summary.

kristen pol’s picture

Category: Bug report » Support request
Status: Active » Closed (works as designed)

I'm an idiot. Just use an integer type. I'm so tired :/

lauriii’s picture

Category: Support request » Bug report
Status: Closed (works as designed) » Active

Thank you @kristen pol for updating this! I'm keeping this as a minor bug report as it impacts DX. This may be still desired because of that.

shyam_bhatt’s picture

Status: Active » Needs review

We can add the prop with type integer as per the below code. It will generate a new filter level with no error.

    level:
      type: integer
      title: Level
      description: 'Semantic level: 1, 2, 3, 4.'
      default: 2
      enum:
        - 1
        - 2
        - 3
        - 4
      examples:
        - 2
kristen pol’s picture

See comment #2 above

shyam_bhatt’s picture

yes, Kristen pol. Thanks for the comment. I added the code for better visibility.

kristen pol’s picture

Status: Needs review » Active

Moving back to active .

kristen pol’s picture

Priority: Minor » Normal

Running into this for the "data card" because you can have "+100" or "50" or similar. If it's a string, then the "50" won't work, but if it's an integer than "+100" won't work. Moving to normal.

wim leers’s picture

AFAICT this is once again a duplicate of #3463842: [META] Redux sync on ALL prop types, not just ones with a single [value] property, because the options_select field widget for the list_integer field type generates something like

<select>
…
<option value="3">3</option>
<option value="4">4</option>
…
</select>

…  i.e. those are <em>string</em> values in the <code>value

attribute for each <option>, the client-side must know when to map those to integers.

kristen pol’s picture

bnjmnm’s picture

Status: Postponed » Closed (duplicate)