react-jsonschema-form icon indicating copy to clipboard operation
react-jsonschema-form copied to clipboard

`title` keyword does not work for some object properties

Open michal-kurz opened this issue 1 year ago • 2 comments

Prerequisites

What theme are you using?

core

Version

5.6.2

Current Behavior

With the following schema, only first property (t) gets its title displayed properly. The second property (t2) displays the property name as a title (playground link):

{
  "type": "object",
  "properties": {
    "t": {
      "type": "string",
      "title": "TITLE"
    },
    "t2": {
      "type": "string",
      "title:": "TITLE"
    }
  }
}

This behaviour seems to be related to property name and order, and can be widely reproduced with many different keys (example playground).

It can be circumvented via ui:title (playground link)

Expected Behavior

I am expecting all fields to be titled TITLE

Steps To Reproduce

See the playgrounds above

Anything else?

I'm not sure what to think of this, it seems to me like the title keyword is fundamentally broken in current release - so maybe I'm just missing something.

michal-kurz avatar Dec 09 '23 21:12 michal-kurz

Thanks for the report @michal-kurz --this is a strange issue. The issue persists across all themes, so it's probably in a shared component like SchemaField.

nickgros avatar Dec 15 '23 20:12 nickgros

@michal-kurz I think there's just a typo in the schema, "title:" should be "title". Can you verify if this is the issue? 🙂

nickgros avatar Dec 15 '23 20:12 nickgros

@nickgros Yeah... I feel pretty stupid. Both my colleague and I spent over an hour each on this 😅

Thanks for pointing it out, and sorry for wasting your time

michal-kurz avatar Mar 15 '24 13:03 michal-kurz