Add support for input type = "number"

Created on 3 March 2022, almost 3 years ago
Updated 5 May 2024, 8 months ago

Problem/Motivation

Currently, numeric exposed filters have type "text". This leads to lack of controls that allow a user to change values without using keyboard (arrows). See screenshot:

Furthermore, even if we change field type programmatically, it will not be affected by "Autosubmit delay" function, therefore using arrows or manually putting values into the fields will submit the filter instantly.

Proposed resolution

Add the ability to use "number" input type for numeric filters and add autosubmit delay support for them.

Thanks!

โœจ Feature request
Status

Fixed

Version

6.0

Component

User interface

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    So this appears to be an issue in core but maybe this module could fix in the meantime.

  • Merge request !64Resolve #3267495 "Add support for" โ†’ (Merged) created by smustgrave
  • Status changed to Needs review 8 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Added a Number filter plugin.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia siddharthjain

    Hi there,

    I have reviewed the above MR with the below steps performed:

    1. Added a exposed filter using Number type field
    2. Added Number filter plugin in BEF and added min and max values

    Here the outcomes:

    1. The Number filter plugin gets added
    2. After saving the BEF settings the min and max values are not getting saved.

    We can update the default value for min and max fields to look like this:
    '#default_value' => !empty($this->configuration['min']) ? $this->configuration['min'] : '',

    Other than this the Number filter plugin works smoothly, thanks for the functionality.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States bernardm28 Tennessee

    I tested this using drupalpod 10.1.x with demo_umami.

    It looks to me like the min-max values are being saved but the plugin is not reading values that are already stored in config.
    Even after you enter min 3 and max 30 and verify it works the form will load with empty values.

    I used the /en/recipes view with the exposed filter of (field_cooking_time)

    The up arrow seems to work well. I was able to increase the values with it and the min and max work as expected on the expose form but the plugin did not seem to read previously saved values.

    Because it does not load the previously saved min max values on the config form it probably needs to go back to needs work.

  • Status changed to Needs work 8 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States bernardm28 Tennessee
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Not sure I follow reading the saved forms. The min/max sets the attributes on the input. So nothing will load but html validation will prevent the form submission if the values are outside that.

  • Pipeline finished with Success
    8 months ago
    Total: 394s
    #148733
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States bernardm28 Tennessee

    The image above is an example of what I would expect if I set the minimum and maximum values and go back into the config form. I would expect those values to load from the save config and allow me to change them again. Unfortunately, the form values will be empty no matter what.

    The exposed filter worked as expected but the config form values for min and max was empty.

    I modified Number.php to match what is used in NumericItemBase.php.

    It should be working as expected now.

  • Status changed to Needs review 8 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States bernardm28 Tennessee
  • Pipeline finished with Success
    8 months ago
    Total: 222s
    #148735
  • Status changed to RTBC 8 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States kwiseman

    I tested the Number filter in Drupalpod 10.1.x with the Umami demo after the last 2 commits by adding an exposed filter for number of servings to the Recipes view, and it works as expected. I wasn't sure if it mattered that the default values for min and max were empty strings (on lines 36 and 37 of src/Plugin/better_exposed_filters/filter/Number.php), so I tried setting them both back to NULL, and it still worked as expected.

  • Status changed to Needs work 8 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Believe the min and max should probably remain NULL but definitely donโ€™t think empty string. If these values arenโ€™t set the attributes shouldnโ€™t appear.

    Also string donโ€™t think matches the schema we are adding

  • Status changed to RTBC 8 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States bernardm28 Tennessee

    Seems to work as expected.

  • Pipeline finished with Success
    8 months ago
    Total: 222s
    #149656
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Saving credit.

    Will merge tomorrow, plan a release Friday

  • Status changed to Fixed 8 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany tobiasb Berlin

    FullyValidatable as a constraint is not valid for Drupal core < 10.3. See CR https://www.drupal.org/node/3404425.

    So I would just leave as a todo.

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

Production build 0.71.5 2024