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

  1. Create or edit an existing webform
  2. Add a Number component and edit its options
  3. Set "minimum" to 0
  4. Set "maximum" to 22
  5. Set "step" to 10
  6. Under "Display" set "Element type" to "Select list"
  7. 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

Issue fork webform-3016408

Command icon 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

ddiestra created an issue. See original summary.

ddiestra’s picture

liam morland’s picture

Title: Number selector separator fix. » Number selector separator fix
Status: Active » Needs review

Please explain what the problem is and what the patch is doing to fix it.

Status: Needs review » Needs work

The last submitted patch, 2: webform-number_select_separator_fix-3016408.patch, failed testing. View results

coderbrandon’s picture

Rerolling 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.

liam morland’s picture

My question in #3 remains.

coderbrandon’s picture

@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.

liam morland’s picture

Category: Task » Feature request

Those two items should probably be separate issues.

joshf’s picture

Title: Number selector separator fix » Add max value in stepped number selector
Issue summary: View changes
StatusFileSize
new701 bytes

Here is a patch for change 1 in Brandon's comment #7.

joshf’s picture

I opened #3215936 for change 2 in #7.

luisrhaas’s picture

Status: Needs work » Needs review

Hi!

I think joshf did the remain tasks, I changed to "needs review".

Liam, if you need something more please let us know.

Thank you

Johnny Santos’s picture

Assigned: Unassigned » Johnny Santos

Going for the review

liam morland’s picture

This should be put into an issue fork and merge request.

Johnny Santos’s picture

Assigned: Johnny Santos » Unassigned
Status: Needs review » Reviewed & tested by the community
StatusFileSize
new28.96 KB

I just tested and its working as intended, screenshot added.
I made a issue fork and the merge request, as asked by Liam.

Johnny Santos’s picture

Status: Reviewed & tested by the community » Needs work

I'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.

liam morland’s picture

Issue tags: +Need tests

Thanks 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.

sophiavs’s picture

Assigned: Unassigned » sophiavs

Hi, i'll be working on those coding standards issues and submit the new patch.

sophiavs’s picture

StatusFileSize
new436 bytes

Testing if it'll pass on the tests

sophiavs’s picture

StatusFileSize
new698 bytes
sophiavs’s picture

Assigned: sophiavs » Unassigned
Status: Needs work » Needs review

As the code with the standarts passed on the tests i will pass to review the issue

lucassc’s picture

Assigned: Unassigned » lucassc

Hi! I'll review.

lucassc’s picture

Assigned: lucassc » Unassigned
Issue summary: View changes
Status: Needs review » Reviewed & tested by the community

I 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.

liam morland’s picture

Status: Reviewed & tested by the community » Needs work

Please put the latest patch into a merge request.

lucassc’s picture

Status: Needs work » Needs review

It's up to date now, I just rerolled MR !167's branch to sync it up with 7.x-4.x.

lucassc’s picture

Tests are still failing, but as they passed in #20 (as a patch) I believe it may be related to what was said in #17:

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.

lucassc’s picture

StatusFileSize
new760 bytes

Uploading a patch from MR's plain diff to double check if it's a false fail.

vitorbs’s picture

Assigned: Unassigned » vitorbs

I'll do the review.

liam morland’s picture

The comment being removed says this:

- // @todo HTML5 browsers apparently do not include the max value if it does
- // not line up with step. Restore this if needed in the future.

What is the current behaviour in browsers? Does it work with this patch in a consistent way?

vitorbs’s picture

Assigned: vitorbs » Unassigned
Status: Needs review » Reviewed & tested by the community

As 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.

liam morland’s picture

Status: Reviewed & tested by the community » Fixed

Thanks everyone!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.