Request: In handlers/views_handler_filter.inc, please increase the sort order weight option (#delta) of the exposed group filters to a workable number.

i.e. Change '#delta' => 10 to '#delta' => 60

Reason: Sort breaks, and does unpredictable sorting, if you use more than 20 options. E.g. say you have have an exposed grouped filter with a price drop down of more than 20 options, sorting will not work after 20 items, it will always spit out a different order than what you specify.

Example:

Before fix:
views sort order broken

...

After fix:
Views exposed group filters sort order after fix

You can see what's going on by showing the row weights, by clicking the "Show row weights" link:

show row weights

The problem:
What views does, when you drag and drop sort, is assign a unique weight to each selection up to 20, then after that it doesn't know what to do, hence you get unpredictable results.

Here's the fix:

If you increase the count of weight selection (#delta) to a sufficient number then views is able to assign a unique weight to each row...

Anhow...

Starting line 1000 change:

        'weight' => array(
          '#type' => 'weight',
          '#delta' => 10,
          '#default_value' => $default_weight++,
          '#attributes' => array('class' => array('weight')),
        ),

To this:

        'weight' => array(
          '#type' => 'weight',
          '#delta' => 60,
          '#default_value' => $default_weight++,
          '#attributes' => array('class' => array('weight')),
        ),
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

duntuk’s picture

Issue summary: View changes
duntuk’s picture

Issue summary: View changes
bradezone’s picture

Yep, this fix is totes needed officially.

bradallenfisher’s picture

is there a hook available to override this the right way?

bradallenfisher’s picture

Would increasing the the delta to a range of -50 to 50 be disadvantageous to other areas of this module?
I "CAN" hack views_filter_handler.inc but would obviously prefer not to... I assume that 100 is a sane amount for sorting in this case where 20 falls a tad short?

bradezone’s picture

Just curious, why isn't this patched into the official release yet? It literally involves changing one digit.

bradezone’s picture

Priority: Normal » Major
schady4’s picture

Though not official i added a patch to do what the author has asked 10 => 60 for delta

deetergp’s picture

Rerolled patch from #8 to apply to Views 7.x-3.14 and to conform to Drupal patch naming convention.

gcaudle’s picture

Having to repeat this every time I need to add categories to a long view filter is ANNOYING. This needs to be officially patched.

Stevel’s picture

Title: Exposed filters group: increase weight sort count (#delta) » Sorting grouped exposed filter breaks when there are more than 20 criteria
Category: Feature request » Bug report
Status: Active » Needs review

This is definitely a bug report, and setting this to 'Needs review' since there is a patch to review here.

The last submitted patch, 8: viewsweightchange.patch, failed testing.

zalak.addweb’s picture

Issue tags: +views
sagesolutions’s picture

This is also a bug in Drupal 8.

Please fix!

gcaudle’s picture

3 months later and I am fixing this AGAIN for another installation. Seriously, how hard is it to change one number in the code?

sander-martijn’s picture

bug still exists so every time you update views it will come back until this gets commited. patch #9 still works, no idea why this still hasn't been applied (and as someone recently commented the bug has been ported to 8).

gcaudle’s picture

Here I am, back to complain about this one more time. More than 20 options in a drop down is NORMAL and should be handled by the module. Change the one number.

Stevel’s picture

This updated patch makes the #delta conform to the number of items displayed in the form. Adding a row reloads the form, so then the number is increased automatically. This should work for any number of items.

rekaeps’s picture

I just applied patch in #18 to our site. It works.

Thanks all, this was an annoying bug. Let's hope it stays squashed this time.

k.elizabeth’s picture

Another vote for this being addressed in the next module release. This is a really irritating bug.

Stevel’s picture

As long as this remains in the 'Needs review' state, it won't be committed.

Perhaps someone (other than me, since I wrote the patch in #18) could mark the issue as RTBC if it works well?

ruha’s picture

Status: Needs review » Reviewed & tested by the community

This patch is working great for me for an Alphabetical filter solution. Changing to RTBC

Stevel’s picture

Status: Reviewed & tested by the community » Closed (duplicate)
Related issues: +#1984694: Increase weight #delta along with the number of grouped filters

The patch doesn't apply any more, because there was a duplicate issue (which got committed!): #1984694: Increase weight #delta along with the number of grouped filters