Problem/Motivation
Using a select list on a Number component with stepped values may result in the "max" value not being shown as a selection option.
Steps to reproduce
- Create or edit an existing webform
- Add a Number component and edit its options
- Set "minimum" to 0
- Set "maximum" to 22
- Set "step" to 10
- Under "Display" set "Element type" to "Select list"
- Save the component and view the webform
Expected: The last option in the select list is "22"
Actual: The last option in the select list is "20"
Proposed resolution
Add a checkbox option next to "step" to add the "Max" value, even if it is not a natural step.
Remaining tasks
The attached patch enables the functionality across the board, using existing commented-out code. This needs to be built out to be an option configurable on a per-component basis.
User interface changes
Adding a new configuration option for the Number component.
API changes
Unknown
Data model changes
Unknown

| Comment | File | Size | Author |
|---|---|---|---|
| #27 | 3016408-27.patch | 760 bytes | lucassc |
| #20 | 3016408-20.patch | 698 bytes | sophiavs |
| #9 | max_value_in_stepped_number_selector-3016408-9.patch | 701 bytes | joshf |
| #15 | Captura de Tela 2022-04-04 às 15.12.32.png | 28.96 KB | Johnny Santos |
Issue fork webform-3016408
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
ddiestra commentedComment #3
liam morlandPlease explain what the problem is and what the patch is doing to fix it.
Comment #5
coderbrandon commentedRerolling this for the newest version. This patch is mostly because of client requirements but I could see the value of having these changes being something configurable on the number component.
Comment #6
liam morlandMy question in #3 remains.
Comment #7
coderbrandon commented@Liam - There are 2 changes:
1. Include the max value even if it doesn't exactly match to the step
2. Key the options by the exact value instead of the numeric value. Ex: "1000" becomes "1,000.00" based on the component's configuration.
FYI, this isn't in any state to be merged into the module. There would need to be some additional work to make these changes configurable on the component itself instead of being blindly applied.
Comment #8
liam morlandThose two items should probably be separate issues.
Comment #9
joshf commentedHere is a patch for change 1 in Brandon's comment #7.
Comment #10
joshf commentedI opened #3215936 for change 2 in #7.
Comment #11
luisrhaas commentedHi!
I think joshf did the remain tasks, I changed to "needs review".
Liam, if you need something more please let us know.
Thank you
Comment #12
Johnny Santos commentedGoing for the review
Comment #13
liam morlandThis should be put into an issue fork and merge request.
Comment #15
Johnny Santos commentedI just tested and its working as intended, screenshot added.
I made a issue fork and the merge request, as asked by Liam.
Comment #16
Johnny Santos commentedI'm moving back to 'needs work, since the tests are not passing.
I' dont know the reason since I didnt change anything from the patch.
BTW: drupal 9 has the same issue happening with max value and the steps.
Comment #17
liam morlandThanks for the merge request.
There is a coding standards problem (indentation) introduced by this change.
This needs tests.
Sometimes tests on merge requests falsely fail. Instead, a patch needs to be uploaded. This is reported in #3194156: Patches and Merge Requests lead to different test results.
Comment #18
sophiavs commentedHi, i'll be working on those coding standards issues and submit the new patch.
Comment #19
sophiavs commentedTesting if it'll pass on the tests
Comment #20
sophiavs commentedComment #21
sophiavs commentedAs the code with the standarts passed on the tests i will pass to review the issue
Comment #22
lucasscHi! I'll review.
Comment #23
lucasscI applied the patch in #20 for branch 7.x-4.x and works well, tests are passing and there's no coding standards problem introduced by the change anymore.
Comment #24
liam morlandPlease put the latest patch into a merge request.
Comment #25
lucasscIt's up to date now, I just rerolled MR !167's branch to sync it up with 7.x-4.x.
Comment #26
lucasscTests are still failing, but as they passed in #20 (as a patch) I believe it may be related to what was said in #17:
Comment #27
lucasscUploading a patch from MR's plain diff to double check if it's a false fail.
Comment #28
vitorbs commentedI'll do the review.
Comment #29
liam morlandThe comment being removed says this:
What is the current behaviour in browsers? Does it work with this patch in a consistent way?
Comment #30
vitorbs commentedAs the tests passed for the patch I think we can consider it a false fail.
If no one else disagrees I think this can be marked as RTBC.
Comment #32
liam morlandThanks everyone!