jQuery UI slider Exposed filter always applied

Created on 6 September 2024, 4 months ago

Problem/Motivation

Hi!

I'm trying to fix the bef slider filter to be displayed in the filters summary area from the views_filters_summary module.
I think I've faced with the same issue created some years ago https://www.drupal.org/project/better_exposed_filters/issues/3145983 β†’ , but in 6.0.6.

Is it possible to provide some fix to not submit the slider's input values if the values are equal to the min and max values of the widget?

I'm calculating mix and max values and setting them to the filter's options in HOOK_better_exposed_filters_options_alter().

I'm trying to use hook_batch_views_filters_summary_info_alter() to add the slider filter's value, but I don't have a way to get min and max value from the filter's options in this hook. Is there any way or I have to re-calculate those values there? Or we need somehow to not submit min and max values when the views exposed form is submitted.

Any suggestions?

Thanks!

πŸ› Bug report
Status

Active

Version

6.0

Component

Code

Created by

πŸ‡ΊπŸ‡¦Ukraine khiminrm

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

Comments & Activities

  • Issue created by @khiminrm
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    jquery slider was removed in 7.0.x

  • πŸ‡ΊπŸ‡¦Ukraine khiminrm

    @smustgrave thanks for the reply!

    But I didn't write about jQuery. I've just compared code in bef_sliders.js between 6.0.x and 7.0.x and they look similar, no? but the issue exists and I'm not sure this is somehow related to jQuery.

    I've just created some draft code to set form state values for the field in custom validation function for the exposed form and looks like it works. But not sure maybe there can be better solution.

    My draft temp solution:

    function _my_test_module_exposed_validate(&$form, FormStateInterface $form_state) {
      $values = $form_state->getValues();
      if (!isset($values['price_range'])) {
        return;
      }
      $options_min = $form['price_range']['#attached']['drupalSettings']['better_exposed_filters']['slider_options']['price_range']['min'];
      $options_max = $form['price_range']['#attached']['drupalSettings']['better_exposed_filters']['slider_options']['price_range']['max'];
      if ($options_min == $values['price_range']['min'] && $options_max == $values['price_range']['max']) {
        $values['price_range']['min'] = '';
        $values['price_range']['max'] = '';
        $form_state->setValues($values);
      }
    }
    
    
  • Status changed to Postponed: needs info about 1 month ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    The title of the ticket mentions jQuery UI Slider. This was removed in 7.0.x and replaced with ui slider.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave
Production build 0.71.5 2024