Skip to content

feat: add max and min options to number input#1480

Merged
TCMeldrum merged 7 commits into
developfrom
252-add-max-and-min-to-number-input
May 26, 2026
Merged

feat: add max and min options to number input#1480
TCMeldrum merged 7 commits into
developfrom
252-add-max-and-min-to-number-input

Conversation

@TCMeldrum
Copy link
Copy Markdown
Contributor

@TCMeldrum TCMeldrum commented Apr 15, 2026

Closes UserOfficeProject/issue-tracker#252

Description

This PR introduces min and max options to the number input fields in the application.

Motivation and Context

The change was required to provide more flexibility and control over the input fields, enabling the application to handle a wider range of data validation scenarios and improve the user experience.

Changes

  1. Added new fields (numberMin, numberMax, numberMinInclusive, numberMaxInclusive) to the NumberInputConfig class, which control the minimum and maximum allowed values in number input fields.
  2. Adjusted the createNumberInputQuestion function to handle these new options.
  3. Updated the QuestionNumberForm component to include new form fields for the new options, complete with validation logic.
  4. Updated test cases to reflect the new changes and ensure they are working as expected.

How Has This Been Tested?

Fixes Jira Issue

https://jira.ess.eu//browse/

Depends On

Tests included/Docs Updated?

  • I have added tests to cover my changes.
  • All relevant doc has been updated

@TCMeldrum TCMeldrum requested a review from a team as a code owner April 15, 2026 13:21
@TCMeldrum TCMeldrum requested review from Scott-James-Hurley and removed request for a team April 15, 2026 13:21
@TCMeldrum TCMeldrum requested a review from jekabs-karklins May 20, 2026 14:15
})
),
numberMin: Yup.number()
.typeError('Minimum score must be a number')
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Should we also call this "Value must be a number" the same as for numberMax test?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missed chnaging that one thanks!

component={TextField}
fullWidth
inputProps={{ 'data-cy': 'numberMin' }}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
Copy link
Copy Markdown
Contributor

@jekabs-karklins jekabs-karklins May 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: I noticed that when the value for minimum/maximum is cleard it hides the checkbox, which keeps the state. It is just maybe little illogical to have min set as null and it being inclusive? Maybe we should clear the flag/checkbox (inclusive) in that case? See the recording.

Kooha-2026-05-26-13-49-58.webm

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated it to reset to false on the blur event when min is cleared

Copy link
Copy Markdown
Contributor

@jekabs-karklins jekabs-karklins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am approving as it looks good, but I added two small comments still please check them.

@TCMeldrum TCMeldrum enabled auto-merge May 26, 2026 15:30
@TCMeldrum TCMeldrum merged commit 2215a12 into develop May 26, 2026
22 checks passed
@TCMeldrum TCMeldrum deleted the 252-add-max-and-min-to-number-input branch May 26, 2026 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

As a user I should be allowed to select the min/max number of weeks access dependant on my access route

4 participants