Skip to content

Angular material array renderer is showing wrong number of errors in the badge on top of the icon #2473

@martin-trajanovski

Description

@martin-trajanovski

Describe the bug

When using the default ArrayLayoutRenderer provided by @jsonforms/angular-material package I can see wrong number displayed in the errors icon badge. This is because the count is done using matBadge="{{ this.error.split('').length }}" which is wrong as it is splitting the error by empty string '' and basically counting every character that is in the message. In my case the message is is a required property and the number shown is 22 as it contains 22 characters. Here is an example:

Image

Expected behavior

The expected behavior should count the number of errors and not the characters. The split should be by a newline character \n instead. Something like this: matBadge="{{ this.error.split('\n').length }}" Here is an example:

Image

Steps to reproduce the issue

  1. Add an array of objects in the schema. Something like this:
    { "type": "object", "properties": { "creators": { "type": "array", "minItems": 1, "items": { "type": "object", "properties": { "name": { "type": "string", "title": "Name", "$dataciteRequired": true }, "nameType": { "type": "string", "title": "Name Type", "$dataciteRequired": false, "enum": ["Personal", "Organizational"] }, "givenName": { "type": "string", "title": "Given Name", "$dataciteRequired": false }, "familyName": { "type": "string", "title": "Family Name", "$dataciteRequired": false } } } } } }

Screenshots

No response

Which Version of JSON Forms are you using?

v3.6.0

Package

Core, Angular Material Renderers, Angular Bindings

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions