Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Titles specified in UI Schema do not render #3531

Closed
4 tasks done
NthCycle opened this issue Mar 20, 2023 · 0 comments
Closed
4 tasks done

Titles specified in UI Schema do not render #3531

NthCycle opened this issue Mar 20, 2023 · 0 comments
Labels
bug needs triage Initial label given, to be assigned correct labels and assigned

Comments

@NthCycle
Copy link

NthCycle commented Mar 20, 2023

Prerequisites

What theme are you using?

mui

Version

5.x

Current Behavior

Titles specified in UiSchema do not render for text widgets when using MUI, Material UI , Chakra, Fluent, or Semantic

Expected Behavior

I expect the titles specified in the UiSchema to override the property name, as they do with other themes.

Steps To Reproduce

In the playgound,
Schema:

  "type": "object",
  "properties": {
    "bad": {
      "type": "string"
    }
  }
}

UiSchema:

  "bad": {
    "ui:title": "good"
  }
}

Possible Solution

This widget implements the expected behavior. All that is necessary is adding label = {getUiOptions(props.uiSchema).title ?? props.label} to the return statement of the core TextWidget

import { getTemplate, FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps, getUiOptions } from '@rjsf/utils';

/** The `TextWidget` component uses the `BaseInputTemplate`.
 *
 * @param props - The `WidgetProps` for this component
 */
export default function TextWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
  props: WidgetProps<T, S, F>
) {
  const { options, registry } = props;
  const BaseInputTemplate = getTemplate<'BaseInputTemplate', T, S, F>('BaseInputTemplate', registry, options);
  return <BaseInputTemplate {...props} label = {getUiOptions(props.uiSchema).title ?? props.label}/>;
}
@NthCycle NthCycle added bug needs triage Initial label given, to be assigned correct labels and assigned labels Mar 20, 2023
heath-freenome added a commit to heath-freenome/react-jsonschema-form that referenced this issue Mar 22, 2023
…layed correctly

Fixes rjsf-team#827, rjsf-team#2636, rjsf-team#2399, rjsf-team#2791, rjsf-team#3231, and rjsf-team#3531 so that titles, descriptions and labels are picked up from uiSchema then schema and are hidden correctly when `label` in uiSchema is false
- Updated `@rjsf/utils` to add `displayLabel` to `WidgetProps`
- Updated `@rjsf/core` to fix the bugs as follows:
  - Updated `ArrayField`, `MultiSchemaField`, `StringField` to pass the label as `uiOptions.title || schema.title || name` as well as passing `displayLabel` from the `uiOptions`
  - Updated `ObjectField` to not pass `title` or `description` when `displayLabel` is false and `ObjectTitleTemplate` to only check `title` and `description`
  - Updated `ArrayFieldDescriptionTemplate` and `ArrayFieldTitleTemplate` to pass `globalUiOptions` into `getUiOptions` to pick up the global `label`
  - Updated `CheckboxWidget` to not show description when `displayLabel` is false
- Updated `@rjsf/antd` to fix the bugs as follows:
  - Updated `ObjectTitleTemplate` to only check `title` and `description` since they will be falsey from `ObjectField` when `displayLabel` is false
  - Updated `CheckboxWidget` to render the description using the `DescriptionFieldTemplate`, except when `displayLabel` is false
- Updated `@rjsf/bootstrap-4` to fix the bugs as follows:
  - Updated `ObjectTitleTemplate` to only check `title` and `description` since they will be falsey from `ObjectField` when `displayLabel` is false
  - Updated `CheckboxWidget` to render the description using the `DescriptionFieldTemplate`, except when `displayLabel` is false
  - Updated `RangeWidget` to only pass `label` in the `extraProps` when `displayLabel` is true
- Updated `@rjsf/chakra-ui` to fix the bugs as follows:
  - Updated `ObjectTitleTemplate` to only check `title` and `description` since they will be falsey from `ObjectField` when `displayLabel` is false
  - Updated `CheckboxWidget` to render the description using the `DescriptionFieldTemplate`, except when `displayLabel` is false
  - Updated `BaseInputTemplate`, `CheckboxesWidget`, `RadioWidget`, `RangeWidget`, `SelectWidget`, `TextareaWidget` and `UpDownWidget` to hide `label` when `displayLabel` and `label` are falsy
  - Updated test snapshots due to fixed bugs
- Updated `@rjsf/fluent-ui` to fix the bugs as follows:
  - Updated `ObjectTitleTemplate` to only check `title` and `description` since they will be falsey from `ObjectField` when `displayLabel` is false
  - Updated `CheckboxWidget` to render the description using the `DescriptionFieldTemplate`, except when `displayLabel` is false
  - Updated `BaseInputTemplate`, `CheckboxesWidget`, `ColorWidget`, `DateWidget`, `RadioWidget`, `RangeWidget`, `SelectWidget` and `UpDownWidget` to hide `label` when `displayLabel` and `label` are falsy
  - Updated `FieldTemplate` to hide description when `displayLabel` is false
  - Updated test snapshots due to fixed bugs
- Updated `@rjsf/material-ui` and `@rjsf/mui` to fix the bugs as follows:
  - Updated `ObjectTitleTemplate` to only check `title` and `description` since they will be falsey from `ObjectField` when `displayLabel` is false
  - Updated `CheckboxWidget` to render the description using the `DescriptionFieldTemplate`, except when `displayLabel` is false
  - Updated `BaseInputTemplate`, `CheckboxesWidget`, `RadioWidget`, `RangeWidget` and `SelectWidget` to hide `label` when `displayLabel` and `label` are falsy
  - Updated test snapshots due to fixed bugs
- Updated `@rjsf/semantic-ui` to fix the bugs as follows:
  - Updated `ObjectTitleTemplate` to only check `title` and `description` since they will be falsey from `ObjectField` when `displayLabel` is false
  - Updated `CheckboxWidget` to render the description using the `DescriptionFieldTemplate`, except when `displayLabel` is false
  - Updated `BaseInputTemplate`, `CheckboxesWidget`, `SelectWidget` and `TextareaWidget` to hide `label` when `displayLabel` and `label` are falsy
  - Updated test snapshots due to fixed bugs
- Updated the `widget` documentation for the new `displayLabel` prop
- Updated the `CHANGELOG.md` file accordingly
heath-freenome added a commit to heath-freenome/react-jsonschema-form that referenced this issue Mar 22, 2023
…layed correctly

Fixes rjsf-team#827, rjsf-team#2636, rjsf-team#2399, rjsf-team#2791, rjsf-team#3231, and rjsf-team#3531 so that titles, descriptions and labels are picked up from uiSchema then schema and are hidden correctly when `label` in uiSchema is false
- Updated `@rjsf/utils` to add `displayLabel` to `WidgetProps`
- Updated `@rjsf/core` to fix the bugs as follows:
  - Updated `ArrayField`, `MultiSchemaField`, `StringField` to pass the label as `uiOptions.title || schema.title || name` as well as passing `displayLabel` from the `uiOptions`
  - Updated `ObjectField` to not pass `title` or `description` when `displayLabel` is false and `ObjectTitleTemplate` to only check `title` and `description`
  - Updated `ArrayFieldDescriptionTemplate` and `ArrayFieldTitleTemplate` to pass `globalUiOptions` into `getUiOptions` to pick up the global `label`
  - Updated `CheckboxWidget` to not show description when `displayLabel` is false
- Updated `@rjsf/antd` to fix the bugs as follows:
  - Updated `ObjectTitleTemplate` to only check `title` and `description` since they will be falsey from `ObjectField` when `displayLabel` is false
  - Updated `CheckboxWidget` to render the description using the `DescriptionFieldTemplate`, except when `displayLabel` is false
- Updated `@rjsf/bootstrap-4` to fix the bugs as follows:
  - Updated `ObjectTitleTemplate` to only check `title` and `description` since they will be falsey from `ObjectField` when `displayLabel` is false
  - Updated `CheckboxWidget` to render the description using the `DescriptionFieldTemplate`, except when `displayLabel` is false
  - Updated `RangeWidget` to only pass `label` in the `extraProps` when `displayLabel` is true
- Updated `@rjsf/chakra-ui` to fix the bugs as follows:
  - Updated `ObjectTitleTemplate` to only check `title` and `description` since they will be falsey from `ObjectField` when `displayLabel` is false
  - Updated `CheckboxWidget` to render the description using the `DescriptionFieldTemplate`, except when `displayLabel` is false
  - Updated `BaseInputTemplate`, `CheckboxesWidget`, `RadioWidget`, `RangeWidget`, `SelectWidget`, `TextareaWidget` and `UpDownWidget` to hide `label` when `displayLabel` and `label` are falsy
  - Updated test snapshots due to fixed bugs
- Updated `@rjsf/fluent-ui` to fix the bugs as follows:
  - Updated `ObjectTitleTemplate` to only check `title` and `description` since they will be falsey from `ObjectField` when `displayLabel` is false
  - Updated `CheckboxWidget` to render the description using the `DescriptionFieldTemplate`, except when `displayLabel` is false
  - Updated `BaseInputTemplate`, `CheckboxesWidget`, `ColorWidget`, `DateWidget`, `RadioWidget`, `RangeWidget`, `SelectWidget` and `UpDownWidget` to hide `label` when `displayLabel` and `label` are falsy
  - Updated `FieldTemplate` to hide description when `displayLabel` is false
  - Updated test snapshots due to fixed bugs
- Updated `@rjsf/material-ui` and `@rjsf/mui` to fix the bugs as follows:
  - Updated `ObjectTitleTemplate` to only check `title` and `description` since they will be falsey from `ObjectField` when `displayLabel` is false
  - Updated `CheckboxWidget` to render the description using the `DescriptionFieldTemplate`, except when `displayLabel` is false
  - Updated `BaseInputTemplate`, `CheckboxesWidget`, `RadioWidget`, `RangeWidget` and `SelectWidget` to hide `label` when `displayLabel` and `label` are falsy
  - Updated test snapshots due to fixed bugs
- Updated `@rjsf/semantic-ui` to fix the bugs as follows:
  - Updated `ObjectTitleTemplate` to only check `title` and `description` since they will be falsey from `ObjectField` when `displayLabel` is false
  - Updated `CheckboxWidget` to render the description using the `DescriptionFieldTemplate`, except when `displayLabel` is false
  - Updated `BaseInputTemplate`, `CheckboxesWidget`, `SelectWidget` and `TextareaWidget` to hide `label` when `displayLabel` and `label` are falsy
  - Updated test snapshots due to fixed bugs
- Updated the `widget` documentation for the new `displayLabel` prop
- Updated the `CHANGELOG.md` file accordingly
heath-freenome added a commit to heath-freenome/react-jsonschema-form that referenced this issue Mar 22, 2023
…layed correctly

Fixes rjsf-team#827, rjsf-team#2636, rjsf-team#2399, rjsf-team#2791, rjsf-team#3231, and rjsf-team#3531 so that titles, descriptions and labels are picked up from uiSchema then schema and are hidden correctly when `label` in uiSchema is false
- Updated `@rjsf/utils` to add `displayLabel` to `WidgetProps`
- Updated `@rjsf/core` to fix the bugs as follows:
  - Updated `ArrayField`, `MultiSchemaField`, `StringField` to pass the label as `uiOptions.title || schema.title || name` as well as passing `displayLabel` from the `uiOptions`
  - Updated `ObjectField` to not pass `title` or `description` when `displayLabel` is false and `ObjectTitleTemplate` to only check `title` and `description`
  - Updated `ArrayFieldDescriptionTemplate` and `ArrayFieldTitleTemplate` to pass `globalUiOptions` into `getUiOptions` to pick up the global `label`
  - Updated `CheckboxWidget` to not show description when `displayLabel` is false
- Updated `@rjsf/antd` to fix the bugs as follows:
  - Updated `ObjectTitleTemplate` to only check `title` and `description` since they will be falsey from `ObjectField` when `displayLabel` is false
  - Updated `CheckboxWidget` to render the description using the `DescriptionFieldTemplate`, except when `displayLabel` is false
- Updated `@rjsf/bootstrap-4` to fix the bugs as follows:
  - Updated `ObjectTitleTemplate` to only check `title` and `description` since they will be falsey from `ObjectField` when `displayLabel` is false
  - Updated `CheckboxWidget` to render the description using the `DescriptionFieldTemplate`, except when `displayLabel` is false
  - Updated `RangeWidget` to only pass `label` in the `extraProps` when `displayLabel` is true
- Updated `@rjsf/chakra-ui` to fix the bugs as follows:
  - Updated `ObjectTitleTemplate` to only check `title` and `description` since they will be falsey from `ObjectField` when `displayLabel` is false
  - Updated `CheckboxWidget` to render the description using the `DescriptionFieldTemplate`, except when `displayLabel` is false
  - Updated `BaseInputTemplate`, `CheckboxesWidget`, `RadioWidget`, `RangeWidget`, `SelectWidget`, `TextareaWidget` and `UpDownWidget` to hide `label` when `displayLabel` and `label` are falsy
  - Updated test snapshots due to fixed bugs
- Updated `@rjsf/fluent-ui` to fix the bugs as follows:
  - Updated `ObjectTitleTemplate` to only check `title` and `description` since they will be falsey from `ObjectField` when `displayLabel` is false
  - Updated `CheckboxWidget` to render the description using the `DescriptionFieldTemplate`, except when `displayLabel` is false
  - Updated `BaseInputTemplate`, `CheckboxesWidget`, `ColorWidget`, `DateWidget`, `RadioWidget`, `RangeWidget`, `SelectWidget` and `UpDownWidget` to hide `label` when `displayLabel` and `label` are falsy
  - Updated `FieldTemplate` to hide description when `displayLabel` is false
  - Updated test snapshots due to fixed bugs
- Updated `@rjsf/material-ui` and `@rjsf/mui` to fix the bugs as follows:
  - Updated `ObjectTitleTemplate` to only check `title` and `description` since they will be falsey from `ObjectField` when `displayLabel` is false
  - Updated `CheckboxWidget` to render the description using the `DescriptionFieldTemplate`, except when `displayLabel` is false
  - Updated `BaseInputTemplate`, `CheckboxesWidget`, `RadioWidget`, `RangeWidget` and `SelectWidget` to hide `label` when `displayLabel` and `label` are falsy
  - Updated test snapshots due to fixed bugs
- Updated `@rjsf/semantic-ui` to fix the bugs as follows:
  - Updated `ObjectTitleTemplate` to only check `title` and `description` since they will be falsey from `ObjectField` when `displayLabel` is false
  - Updated `CheckboxWidget` to render the description using the `DescriptionFieldTemplate`, except when `displayLabel` is false
  - Updated `BaseInputTemplate`, `CheckboxesWidget`, `SelectWidget` and `TextareaWidget` to hide `label` when `displayLabel` and `label` are falsy
  - Updated test snapshots due to fixed bugs
- Updated the `widget` documentation for the new `displayLabel` prop
- Updated the `CHANGELOG.md` file accordingly
heath-freenome added a commit that referenced this issue Mar 24, 2023
…layed correctly (#3533)

* fix: many bugs related to titles, descriptions, labels not being displayed correctly
Fixes #827, #2636, #2399, #2791, #3231, and #3531 so that titles, descriptions and labels are picked up from uiSchema then schema and are hidden correctly when `label` in uiSchema is false
- Updated `@rjsf/utils` to add `displayLabel` to `WidgetProps`
- Updated `@rjsf/core` to fix the bugs as follows:
  - Updated `ArrayField`, `MultiSchemaField`, `StringField` to pass the label as `uiOptions.title || schema.title || name` as well as passing `displayLabel` from the `uiOptions`
  - Updated `ObjectField` to not pass `title` or `description` when `displayLabel` is false and `ObjectTitleTemplate` to only check `title` and `description`
  - Updated `ArrayFieldDescriptionTemplate` and `ArrayFieldTitleTemplate` to pass `globalUiOptions` into `getUiOptions` to pick up the global `label`
  - Updated `CheckboxWidget` to not show description when `displayLabel` is false
- Updated `@rjsf/antd` to fix the bugs as follows:
  - Updated `ObjectTitleTemplate` to only check `title` and `description` since they will be falsey from `ObjectField` when `displayLabel` is false
  - Updated `CheckboxWidget` to render the description using the `DescriptionFieldTemplate`, except when `displayLabel` is false
- Updated `@rjsf/bootstrap-4` to fix the bugs as follows:
  - Updated `ObjectTitleTemplate` to only check `title` and `description` since they will be falsey from `ObjectField` when `displayLabel` is false
  - Updated `CheckboxWidget` to render the description using the `DescriptionFieldTemplate`, except when `displayLabel` is false
  - Updated `RangeWidget` to only pass `label` in the `extraProps` when `displayLabel` is true
- Updated `@rjsf/chakra-ui` to fix the bugs as follows:
  - Updated `ObjectTitleTemplate` to only check `title` and `description` since they will be falsey from `ObjectField` when `displayLabel` is false
  - Updated `CheckboxWidget` to render the description using the `DescriptionFieldTemplate`, except when `displayLabel` is false
  - Updated `BaseInputTemplate`, `CheckboxesWidget`, `RadioWidget`, `RangeWidget`, `SelectWidget`, `TextareaWidget` and `UpDownWidget` to hide `label` when `displayLabel` and `label` are falsy
  - Updated test snapshots due to fixed bugs
- Updated `@rjsf/fluent-ui` to fix the bugs as follows:
  - Updated `ObjectTitleTemplate` to only check `title` and `description` since they will be falsey from `ObjectField` when `displayLabel` is false
  - Updated `CheckboxWidget` to render the description using the `DescriptionFieldTemplate`, except when `displayLabel` is false
  - Updated `BaseInputTemplate`, `CheckboxesWidget`, `ColorWidget`, `DateWidget`, `RadioWidget`, `RangeWidget`, `SelectWidget` and `UpDownWidget` to hide `label` when `displayLabel` and `label` are falsy
  - Updated `FieldTemplate` to hide description when `displayLabel` is false
  - Updated test snapshots due to fixed bugs
- Updated `@rjsf/material-ui` and `@rjsf/mui` to fix the bugs as follows:
  - Updated `ObjectTitleTemplate` to only check `title` and `description` since they will be falsey from `ObjectField` when `displayLabel` is false
  - Updated `CheckboxWidget` to render the description using the `DescriptionFieldTemplate`, except when `displayLabel` is false
  - Updated `BaseInputTemplate`, `CheckboxesWidget`, `RadioWidget`, `RangeWidget` and `SelectWidget` to hide `label` when `displayLabel` and `label` are falsy
  - Updated test snapshots due to fixed bugs
- Updated `@rjsf/semantic-ui` to fix the bugs as follows:
  - Updated `ObjectTitleTemplate` to only check `title` and `description` since they will be falsey from `ObjectField` when `displayLabel` is false
  - Updated `CheckboxWidget` to render the description using the `DescriptionFieldTemplate`, except when `displayLabel` is false
  - Updated `BaseInputTemplate`, `CheckboxesWidget`, `SelectWidget` and `TextareaWidget` to hide `label` when `displayLabel` and `label` are falsy
  - Updated test snapshots due to fixed bugs
- Updated the `widget` documentation for the new `displayLabel` prop
- Updated the `CHANGELOG.md` file accordingly

* - Added a new `labelValue()` function to `@rjsf/utils`
- Updated all ui packages to use `labelValue()` as appropriate, in some cases replacing the `schema.title` with `undefined` which is the real value of `schema.title` when label is an empty string
- Added a new `FluentLabel` component by refactoring common code out of `CheckboxesWidget`, `ColorWidget`, `RangeWidget` and `UpDownWidget`

* - Missed one `labelValue()` usage

* Apply suggestions from code review

Fix bug links
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug needs triage Initial label given, to be assigned correct labels and assigned
Projects
None yet
Development

No branches or pull requests

1 participant