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

Why custom UpDownWidget not working for number field?

Open fengye87 opened this issue 1 year ago • 5 comments

Prerequisites

What theme are you using?

core

What is your question?

I though a number-typed field would be a UpDownWidget by default, but it seems not. Is it a bug or expected?

fengye87 avatar Jan 17 '24 10:01 fengye87

Can you please provide an example of this... Bonus points if it is done within our playground

heath-freenome avatar Jan 26 '24 20:01 heath-freenome

I was using rjsf with Mantine, with code like below:

export function Form({ config }: { config: graphql.Form }) {
  return (
    <RJSF
      widgets={{ UpDownWidget }}
      schema={config.schema as any}
      uiSchema={config.uiSchema as any}
      validator={validator}
    />
  );
}

function UpDownWidget(props: WidgetProps) {
  return (
    <NumberInput
      name={props.name}
      label={props.label}
      required={props.required}
      description={props.schema.description}
      min={props.schema.minimum}
      max={props.schema.maximum}
      error={props.rawErrors}
    />
  );
}

I would expect a number typed field (like age in playground) would be an UpDownWidget. But I actually had to specify it in uischema with "ui:widget": "updown" to make it happen.

fengye87 avatar Jan 29 '24 03:01 fengye87