Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,22 @@ describe("NumberInputControl", () => {
rerender(<NumberInputControl node={node} path={node.path} value={99} onChange={vi.fn()} />);
expect(screen.getByRole("spinbutton")).toHaveValue(99);
});

it("does not set min/max attributes for exclusive-only constraints", () => {
const exclusiveNode: NumberInputNode = {
...node,
constraints: { exclusiveMinimum: 0, exclusiveMaximum: 100 },
};
render(
<NumberInputControl
node={exclusiveNode}
path={exclusiveNode.path}
value={1}
onChange={vi.fn()}
/>
);
const input = screen.getByRole("spinbutton") as HTMLInputElement;
expect(input.min).toBe("");
expect(input.max).toBe("");
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ export function NumberInputControl({ node, path, value, onChange }: NumberInputC
const { state, validateField } = useConfigurationBuilder();
const error = state.validationErrors[path] ?? null;
const { constraints } = node;
const min = constraints?.minimum ?? constraints?.exclusiveMinimum;
const max = constraints?.maximum ?? constraints?.exclusiveMaximum;
const min = constraints?.minimum;
const max = constraints?.maximum;

const [draft, setDraft] = useState<string>(() => formatValue(value));
const [prevValue, setPrevValue] = useState<number | null>(value);
Expand Down