Skip to content

Commit

Permalink
Merge pull request #17 from littlecinemadigital/updownlabel
Browse files Browse the repository at this point in the history
up down label
  • Loading branch information
rodrigofuentes authored Jan 14, 2022
2 parents 774d5aa + efeea92 commit 03eef32
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions packages/chakra-ui/src/UpDownWidget/UpDownWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,25 @@ import {
FormControl,
FormLabel,
} from "@chakra-ui/react";
import { WidgetProps } from "@rjsf/core";
import { WidgetProps, utils } from "@rjsf/core";

const { getDisplayLabel } = utils;

const UpDownWidget = ({
id,
schema,
uiSchema,
readonly,
disabled,
label,
value,
onChange,
onBlur,
onFocus,
}: WidgetProps) => {
const displayLabel =
getDisplayLabel(schema, uiSchema) && (!!label || !!schema.title);

const _onChange = (value: string | number) => onChange(value);
const _onBlur = ({
target: { value },
Expand All @@ -29,7 +37,9 @@ const UpDownWidget = ({

return (
<FormControl>
<FormLabel htmlFor={id}>Amount</FormLabel>
{displayLabel ? (
<FormLabel htmlFor={id}>{label || schema.title}</FormLabel>
) : null}
<NumberInput
isDisabled={disabled || readonly}
value={value}
Expand Down

0 comments on commit 03eef32

Please sign in to comment.