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:
...
After fix:
You can see what's going on by showing the row weights, by clicking the "Show row weights" link:
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')),
),
Comment | File | Size | Author |
---|---|---|---|
#18 | views-2228591-weight-change-18-D7.patch | 567 bytes | Stevel |
| |||
#9 | views-weight_change-2228591-9-D7.patch | 515 bytes | deetergp |
| |||
#8 | viewsweightchange.patch | 675 bytes | schady4 |
2014-03-28_162731.png | 5.94 KB | duntuk | |
2014-03-28_162045.png | 2.37 KB | duntuk |
Comments
Comment #1
duntuk CreditAttribution: duntuk commentedComment #2
duntuk CreditAttribution: duntuk commentedComment #3
bradezone CreditAttribution: bradezone commentedYep, this fix is totes needed officially.
Comment #4
bradallenfisher CreditAttribution: bradallenfisher commentedis there a hook available to override this the right way?
Comment #5
bradallenfisher CreditAttribution: bradallenfisher commentedWould 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?
Comment #6
bradezone CreditAttribution: bradezone commentedJust curious, why isn't this patched into the official release yet? It literally involves changing one digit.
Comment #7
bradezone CreditAttribution: bradezone commentedComment #8
schady4 CreditAttribution: schady4 commentedThough not official i added a patch to do what the author has asked 10 => 60 for delta
Comment #9
deetergp CreditAttribution: deetergp at Classic Graphics commentedRerolled patch from #8 to apply to Views 7.x-3.14 and to conform to Drupal patch naming convention.
Comment #10
gcaudle CreditAttribution: gcaudle commentedHaving to repeat this every time I need to add categories to a long view filter is ANNOYING. This needs to be officially patched.
Comment #11
Stevel CreditAttribution: Stevel commentedThis is definitely a bug report, and setting this to 'Needs review' since there is a patch to review here.
Comment #13
zalak.addweb CreditAttribution: zalak.addweb commentedComment #14
sagesolutions CreditAttribution: sagesolutions commentedThis is also a bug in Drupal 8.
Please fix!
Comment #15
gcaudle CreditAttribution: gcaudle commented3 months later and I am fixing this AGAIN for another installation. Seriously, how hard is it to change one number in the code?
Comment #16
sander-martijn CreditAttribution: sander-martijn commentedbug 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).
Comment #17
gcaudle CreditAttribution: gcaudle commentedHere 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.
Comment #18
Stevel CreditAttribution: Stevel commentedThis 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.
Comment #19
rekaeps CreditAttribution: rekaeps as a volunteer commentedI 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.
Comment #20
k.elizabeth CreditAttribution: k.elizabeth commentedAnother vote for this being addressed in the next module release. This is a really irritating bug.
Comment #21
Stevel CreditAttribution: Stevel commentedAs 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?
Comment #22
ruha CreditAttribution: ruha commentedThis patch is working great for me for an Alphabetical filter solution. Changing to RTBC
Comment #23
Stevel CreditAttribution: Stevel commentedThe 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