Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Views filters dragging in the grouping view seems to be a little broken. Here's a gif demonstration about the problem:
Proposed resolution
Figure out is this a template level problem or is there something wrong with the javascript needed for that functionality.
Remaining tasks
- Write test
- Write fix or wait to see if #2215857: Behaviors get attached to removed forms fixes this issue.
User interface changes
-
API changes
-
Comment | File | Size | Author |
---|---|---|---|
#16 | result without attachBehaviors for $form.png | 69.71 KB | michielnugter |
#16 | result with attachBehaviors for $form.png | 75.28 KB | michielnugter |
#16 | 2493945-Views_filters_dragging-16.patch | 3.33 KB | michielnugter |
#16 | interdiff.txt | 1.15 KB | michielnugter |
#12 | 2493945-Views_filters_dragging-12.patch | 986 bytes | cferthorney |
Comments
Comment #1
nod_Preemptively adding to my queue.
Comment #2
droplet CreditAttribution: droplet commentedIt seems #2489826: tabledrag is broken will fix above errors
Comment #3
joelpittetAlso this claims to fix it too... #2496501: Grouped Filters Javascript Improvements
Comment #4
olli CreditAttribution: olli commentedNot a proper fix but this seems to be related to ajax/once behavior. #2 didn't help.
Comment #5
droplet CreditAttribution: droplet commented@olli is correct.
When you click add new group, old table is replaced with new table via Ajax. $(table).data() will be removed.
Downside of 2.0: #2348321: Upgrade to jQuery Once 2.x
Comment #6
joelpittet@droplet or @olli Is there an issue to fix once behaviour?
Maybe delegation is a more proper fix?
Comment #7
olli CreditAttribution: olli commented#6: I don't know. Patch?
Here's an alternative that checks if this.$form was replaced by ajax.
Comment #8
olli CreditAttribution: olli commentedAlmost identical patch in #2215857: Behaviors get attached to removed forms.
Comment #10
pcambraRan into this problem and found that in Firefox fails but Chrome works OK when adding filter groups and sort the stuff around.
Comment #11
dawehnerI'm wondering whether now that we have javascript tests we could actually leverage it.
Comment #12
cferthorneyI've rerolled #7 this against the latest 8.2.x-dev . Please let me know if this actually needs to go against 8.3.x now. No tests added, as I'm uncertain how to test this.
*edited to correct grammar*
Comment #13
droplet CreditAttribution: droplet commentedthis isn't a fix @see #4. :)
Comment #14
cferthorneyMy bad. Rerolled against #2215857 instead.
Comment #16
michielnugter CreditAttribution: michielnugter as a volunteer and at Synetic commentedI extended the test in #2717629: Add filter group for a View fails to add test coverage for this.
I ran the test without any alterations which causes the attachBehaviors to run for the form. This results in an incorrect situation, see the screenshot form the test.
When simply commenting ajax.js line 892:
Drupal.attachBehaviors(this.$form.get(0), settings);
Everything works correctly, which is testable in the UI and will make this test pass (see the different result in the screenshot).
The problem is that the behaviors are attached twice, once for the insert (replacing the form) and once for the form reference that is kept for the beforeSerialize() logic. The mentioned issue #2215857: Behaviors get attached to removed forms really seems relevant here and I think if that issue is fixed, this issue will also be fixed.
Comment #17
michielnugter CreditAttribution: michielnugter as a volunteer and at Synetic commentedComment #18
michielnugter CreditAttribution: michielnugter as a volunteer and at Synetic commentedTrigger test to run to make sure it fails op drupal.org as well.
Note: the test needs refinement before committing it.
Comment #21
michielnugter CreditAttribution: michielnugter as a volunteer and at Synetic commentedMarking this a duplicate of #2215857: Behaviors get attached to removed forms as that fix fixes this issue as well.
Comment #22
hkirsman CreditAttribution: hkirsman commented#2215857 Seems to fix this indeed but you need to rebuild cache.