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')),
        ),

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.

prafull.panchori’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).