Skip to content

A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.

fix(ui): refactor number input props (min,max)

Dinesht0427cd77358cf2
diff --git a/ui/src/components/SchemaForm/components/Input.tsx b/ui/src/components/SchemaForm/components/Input.tsx
index 3a2c0397..d84d7d55 100644
--- a/ui/src/components/SchemaForm/components/Input.tsx
+++ b/ui/src/components/SchemaForm/components/Input.tsx
@@ -50,10 +50,14 @@ const Index: FC<Props> = ({
formData,
readOnly = false,
min = 0,
- max = 65355,
+ max,
inputMode = 'text',
}) => {
const fieldObject = formData[fieldName];
+ const numberInputProps =
+ type === 'number'
+ ? { min, ...(max != null && max > 0 ? { max } : {}) }
+ : {};
const handleChange = (evt: React.ChangeEvent<HTMLInputElement>) => {
const { name, value } = evt.currentTarget;
const state = {
@@ -75,8 +79,7 @@ const Index: FC<Props> = ({
placeholder={placeholder}
type={type}
value={fieldObject?.value || ''}
- min={min}
- max={max}
+ {...numberInputProps}
inputMode={inputMode}
onChange={handleChange}
disabled={readOnly}
diff --git a/ui/src/components/SchemaForm/index.tsx b/ui/src/components/SchemaForm/index.tsx
index 5bde2fdc..171b5f67 100644
--- a/ui/src/components/SchemaForm/index.tsx
+++ b/ui/src/components/SchemaForm/index.tsx
@@ -260,7 +260,7 @@ const SchemaForm: ForwardRefRenderFunction<FormRef, FormProps> = (
enum: enumValues = [],
enumNames = [],
max_length = 0,
- max = 65355,
+ max,
min = 0,
} = properties[key];
const { 'ui:widget': widget = 'input', 'ui:options': uiOpt } =