pnp / pnp/sp-dev-fx-controls-react

DynamicForm Numeric Up/Down buttons not working

Open
#1,956 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
433
Forks
418
Avg merge
5d 6m
Merged PRs (30d)
19

Description

Category

[ ] Enhancement

[X] Bug

[ ] Question

Version

Please specify what version of the library you are using: [3.20.0]

Expected / Desired Behavior / Question

The up/down buttons of numeric fields should increment or decrease the entered value.

Observed Behavior

When there is no limit for the values of the numeric column, SharePoint returns very large values for min and max (I guess max float) which cause the numeric up down buttons in the DynamicForm to stop functioning. If there is no value, clicking one of them will enter 0 in the textbox. Further clicks (or starting with a manually entered value) will not change the number. It is still possible to change the value by typing.

I fixed the issue by adding an additional check for the values, reducing it to MIN/MAX_SAFE_INTEGER in DynamicForm.tsx:

minimumValue: minValue ? (minValue < Number.MIN_SAFE_INTEGER ? Number.MIN_SAFE_INTEGER : minValue) : undefined,
maximumValue: maxValue ? (maxValue > Number.MAX_SAFE_INTEGER ? Number.MAX_SAFE_INTEGER : maxValue) : undefined,

The values get rendered by DynamicField.tsx which already contains this check:

let minValue = minimumValue !== undefined && minimumValue !== -(Number.MAX_VALUE) ? minimumValue : undefined;
let maxValue = maximumValue !== undefined && maximumValue !== Number.MAX_VALUE ? maximumValue : undefined;

So it might be a better solution to fix the DynamicField instead of the DynamicForm.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by inspecting DynamicForm.tsx and DynamicField.tsx, focusing on how numeric minimum and maximum values from SharePoint are passed to the numeric control. Reproduce the behavior with an unbounded numeric field and verify that the up/down buttons change both empty and manually entered values after the bounds are handled consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.