Problem/Motivation

Split off from https://www.drupal.org/node/2215857#comment-11767180.

Stella described the follow steps to reproduce:

My scenario: 5 filters (2 fixed, 3 exposed)

Steps:
- Add 2 new filter groups.
- Leave the 2 fixed filters (filter #1 and #2) in group #1.
- Move filter #3 to group #2 (this is an OR)
- Move filters #4 and #5 to group #3

Result: everything is ok except for filter #5 which stays in group #1.

Caveat: if I move filter #5 to the end of group #3 it doesn't work as above, but if I move it to the top of the group, it stays in group #3. Then after a save, I'm able to move it to the desired position at the end of the group.

A second symptom of this, is that you ARE allowed to drag to zones that shouldn't be available.

Cause:
If you switch to manual mode for dragging you can see the selectbox for the group is not updated.

Proposed resolution

Update the group selectbox correctly.

Remaining tasks

- Get related issues committed as this issue depends on it.
- Write test (extend test in #2717629: Add filter group for a View fails)
- Write patch

User interface changes

-

API changes

-

CommentFileSizeAuthor
#58 apply-changes-to-es6-2825446-58.patch723 byteslauriii
#49 2825446.44_49.interdiff.txt2.05 KBdww
#49 2825446.38_49.interdiff.txt1.45 KBdww
#49 2825446-49.patch4.42 KBdww
#49 2825446-49.test-only.patch3.46 KBdww
#44 interdiff-38-44.txt934 bytesanavarre
#44 2825446-44.patch3.87 KBanavarre
#41 views.view_.test.yml8.35 KBanavarre
#38 2825446-38.patch4.16 KBLendude
#38 2825446-38-TEST_ONLY.patch3.19 KBLendude
#31 views_moving_filters-2825446-31.patch993 bytesPancho
#28 interdiff-22-28.txt5.09 KBanavarre
#28 2825446-28.patch9.44 KBanavarre
#27 2825446-27.patch10.28 KBanavarre
#26 interdiff-22-26.txt6.29 KBanavarre
#26 2215857-2825446-combined.patch8.14 KBanavarre
#24 2825446-with-22.gif343.07 KBanavarre
#22 2825446-moving-a-filter-to-the-end-of-a-Filter-group-in-filter-rearrange-doesnt-work-22.patch7.32 KBPancho
#20 2825446-20-tests-only.patch2.46 KBPancho
#19 2825446-moving-a-filter-to-the-end-of-a-Filter-group-in-filter-rearrange-doesnt-work-19.patch4.04 KBPancho
#16 2825446-moving-a-filter-to-the-end-of-a-Filter-group-in-filter-rearrange-doesnt-work-16.patch4.45 KBPancho
#9 filter_group_order.gif163.68 KBdmsmidt
#9 filter_group_order_new_group.gif428.18 KBdmsmidt
#6 2825446-moving-a-filter-to-the-end-of-a-Filter-group-in-filter-rearrange-doesnt-work-4.patch5.45 KBmichielnugter
#6 interdiff-3-4.txt889 bytesmichielnugter
#3 2825446-moving-a-filter-to-the-end-of-a-Filter-group-in-filter-rearrange-doesnt-work-3.patch4.49 KBmichielnugter
#3 interdiff-2215857.txt2.67 KBmichielnugter
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

michielnugter created an issue. See original summary.

michielnugter’s picture

michielnugter’s picture

I created a test based on the version in #2215857: Behaviors get attached to removed forms (which in turn is based on the not-yet-committed #2717629: Add filter group for a View fails).

It validates updating the group. Interdiff is for the difference from the #2215857: Behaviors get attached to removed forms patch.

Lets check if the patch fails on do.org as well.

Status: Needs review » Needs work
michielnugter’s picture

Status: Needs work » Needs review

I think I found the problem, there was a weird check on the previous row beeing the group title row, which obviously is an incorrect check when not adding an item as the first item.

The patches from the related issues are required to make the test pass (which it now does here). We'll have to wait on the other issues and then report a new patch based on what's in core then.

In the meantime, I'd love feedback on the test and patch.

michielnugter’s picture

Status: Needs review » Needs work

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

dmsmidt’s picture

Priority: Normal » Major
Issue summary: View changes
Issue tags: +Needs title update, +Needs issue summary update
FileSize
428.18 KB
163.68 KB

This is still an actual problem (8.4.x). But there is more wrong with drag and drop in the rearrange form than the title suggests.
The problem renders the UI pretty useless, marking this as major.

Drag and drop when creating a new group is problematic, you can drag to zones that shouldn't be available:

For existing groups, the group ID is not updated after a drop in a different group:

michielnugter’s picture

This behavior is exactly what the patch is for, it should fix both issues.

The issue was waiting on the related issues and there in now. There's another issue which alters the test again pending here: #2832672: [PP-1] Upgrade jcalderonzumba/* for better test performance. I'll keep an eye on this issue and reroll a patch after this issue has been fixed.

michielnugter’s picture

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

mgerbault’s picture

Up !

Doesn't work on Drupal 8.5.x
:(

Is there a patch ?

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Pancho’s picture

Here's patch #6 rerolled against HEAD. I also think we shouldn't postpone this major bug for a phpunit-related issue that has not been commented on for 12 months.

Pancho’s picture

By manual testing I can confirm the latest patch does fix the original problem with moving a filter to the end of the previous filter group. :)

However it doesn't fix the additional bug reported in comment #9 that renders the drag-and-drop interface useless for creating a new filter group.

IMHO let's get the original bug fixed first, and then move on to the second one in #3024891: Drag-and-drop builder won't let me arrange filter groups.

Status: Needs review » Needs work
Pancho’s picture

New version using WebDriverTestBase instead of the deprecated JavascriptTestBase, otherwise still the very same patch from #9 rerolled against HEAD. Don't know if the one test failure disappears, otherwise we need to look into that test again.

Pancho’s picture

Manual testing shows the failing test correctly detects the additional bug, see enclosed test-only patch.

Lendude’s picture

The test here passes with the latest patch from #2215857: Behaviors get attached to removed forms applied too

Pancho’s picture

Status: Needs review » Needs work

The last submitted patch, 22: 2825446-moving-a-filter-to-the-end-of-a-Filter-group-in-filter-rearrange-doesnt-work-22.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

anavarre’s picture

FileSize
343.07 KB

Tried to apply the merged patch in #22 against a test code base and all is well.

$ patch -p1 < 2825446-moving-a-filter-to-the-end-of-a-Filter-group-in-filter-rearrange-doesnt-work-22.patch
patching file core/misc/ajax.es6.js
patching file core/misc/ajax.js
patching file core/modules/views_ui/js/views-admin.js
patching file core/modules/views_ui/tests/src/FunctionalJavascript/FilterCriteriaTest.php

Before the functionality was completely broken / unusable both from a UX and feature POV. With the patch I can add a new group and easily move rows around in the new group. More importantly things are finally saved and working correctly. I've tested exposed filters and I can return (exposed) results correctly without any issue. Good job!

I see #2215857: Behaviors get attached to removed forms was recently updated. Should we update the merged patch accordingly for further testing?

Pancho’s picture

Sure. Go forward!

anavarre’s picture

Updated the merged patch.

EDIT: actually I think I've messed up the merge here. Please ignore.

anavarre’s picture

New attempt at merging the 2 issues.

anavarre’s picture

This should be the most up-to-date combined patch.

dww’s picture

Issue tags: +Needs reroll

#2215857: Behaviors get attached to removed forms is now in core, both 8.6.x and 8.7.x. This needs reroll and cleanup now that a "combined patch" would no longer apply.

Thanks!
-Derek

Pancho’s picture

Version: 8.7.x-dev » 8.6.x-dev

Cool that the other issue got in!
This is a bug, so fix in 8.6.x-dev first.

Pancho’s picture

Status: Needs work » Needs review
FileSize
993 bytes

Just the fix, no further tests.

anavarre’s picture

I installed HEAD to see what the new behavior was like after #2215857: Behaviors get attached to removed forms got committed. To my surprise, everything seems to be working as expected 🤨. I'd like someone else to please confirm/deny this statement because it looks odd to me it'd work all of a sudden without the patch from this issue.

Pancho’s picture

@anavarre: You may have above patch in your composer.json, do you? For me the bug still exists with #2215857-49: Behaviors get attached to removed forms applied but #31 not. Please check again.

Otherwise I would reintroduce the tests, so we can get this to RTBC.

Pancho’s picture

anavarre’s picture

Version: 8.6.x-dev » 8.7.x-dev

@Pancho: no, I tried from scratch with 8.7.x locally and tried again just now with a remote test install. Still couldn't reproduce the issue.

I've switched this to 8.7.x because this is the version against which we should be fixing the bug first and leave it up to core committers to backport to 8.6.x - Could you please try with 8.7.x and report back if you see anything different?

The last submitted patch, 20: 2825446-20-tests-only.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

Lendude’s picture

The test-only file in #20 still fails, so that would indicate the problem still exists in HEAD

Lendude’s picture

The last submitted patch, 38: 2825446-38-TEST_ONLY.patch, failed testing. View results

Lendude’s picture

Title: Moving a filter to the end of a Filter group in filter rearrange doesn't work » Moving a filter to the end of a Filter group in filter rearrange doesn't work but does allow dropping in invalid regions
Issue summary: View changes
Issue tags: -Needs JavaScript testing, -Needs title update, -Needs issue summary update

Updated the IS and title (finally, sorry @dmsmidt!)

anavarre’s picture

FileSize
8.35 KB

I understand we have a test-only patch that demonstrates the problem, but at the risk of being a PITA here, I still cannot reproduce against 8.7.x - I tried several fresh instances with different stacks, and rancomposer clear-caches before installing several times as well. I've attached a test view which takes taxonomy term names and TIDs.

  • Populate the default Tags vocabulary with 3, 4 terms to see the view in action.
  • Try and filter out in the (view) preview by name AND tid to see different terms show up accordingly.

I can create filter groups just fine on my end, without the patch in this issue. Perhaps I'm doing something wrong but I cannot see what exactly ATM.

dww’s picture

Status: Needs review » Needs work

Re: #38 nice work! Almost RTBC...

  1. +++ b/core/modules/views_ui/js/views-admin.js
    @@ -450,7 +450,7 @@
    -        if ($(this.rowObject.element).prev('tr').is('.group-message') && !groupField.is('.views-group-select-' + groupName)) {
    +        if (!groupField.is('.views-group-select-' + groupName)) {
    

    Fix looks great!

  2. +++ b/core/modules/views_ui/tests/src/FunctionalJavascript/FilterCriteriaTest.php
    @@ -61,13 +62,42 @@ public function testFilterCriteriaDialog() {
    -    // Checks that the admin summary is not double escaped.
    -    $this->drupalGet('admin/structure/views/view/who_s_online');
    -    $page = $this->getSession()->getPage();
    -    $this->assertNotNull($page->findLink('User: Last access (>= -15 minutes)'));
    -
    

    Why are we removing this test coverage? Seems unrelated to the fix here. :/

  3. +++ b/core/modules/views_ui/tests/src/FunctionalJavascript/FilterCriteriaTest.php
    @@ -61,13 +62,42 @@ public function testFilterCriteriaDialog() {
    +    // Assert dragging a filter works (#2717629).
    

    I don't remember seeing us put issue nids into comments like this. The nid is also #2717629: Add filter group for a View fails which on a very quick skim doesn't seem related to what this assertion is testing for. Long day, please excuse me if I'm confused. ;)

Re: #41: I tested manually, and yes, it's still broken in 8.7.x HEAD. To see the bug:

  1. Create a view with a lot of filters (does not matter what they are). At least 4.
  2. Click on the "Rearrange" tab to bring up the filter group dialog
  3. Create a 2nd filter group
  4. Move one filter to the new group
  5. Apply
  6. Note that you have 2 filter groups
  7. Click on "Rearrange" again
  8. Try to move a filter from group 1 to the end of group 2.
  9. At this point, if you click "Show row weights", you'll see the filter is still in the wrong group.
  10. Apply
  11. Notice that the filter didn't move and is still in group 1.

I'd make a series of screenshots but that'd take too long. ;)

I'll RTBC as soon as #2 is addressed. #3 is just informational / nit.

Thanks! This bug has been bothering me for ages, will be very happy to see it finally fixed in core. :)

Cheers,
-Derek

anavarre’s picture

Thanks, your step-by-step helped. I wasn't reproducing exactly like that (less filters and not paying attention to the weight). Very glad to see this fixed as well.

anavarre’s picture

Status: Needs work » Needs review
FileSize
3.87 KB
934 bytes

Addressed #2 to get the ball rolling. As to #3, it seems we're adding NIDs in other core files already. E.g.

core/lib/Drupal/Core/Mail/Plugin/Mail/PhpMail.php
91:    // but some MTAs incorrectly replace LF with CRLF. See #234403.
core/lib/Drupal/Core/Session/SessionManager.php
214:    // as #2238561 remains open.

Status: Needs review » Needs work

The last submitted patch, 44: 2825446-44.patch, failed testing. View results

anavarre’s picture

Status: Needs work » Reviewed & tested by the community

Seems there was a reason why those lines got removed. Re-tested #38 and it still returns back green.

Marking RTBC to solicit core committers opinion on the patch readiness.

dww’s picture

Status: Reviewed & tested by the community » Needs review

Sorry, that's not really how RTBC works. ;) If we have known issues, we sort them out ourselves before we bump to RTBC.

Maybe @Lendude can comment on this point? What's up with #42.2?

It seems like that assertion has nothing to do with this issue. Not clear why re-adding it caused #44 to fail, especially since on a quick skim it doesn't seem like it failed in the re-added assertion.

dww’s picture

Assigned: Unassigned » dww
Status: Needs review » Needs work

Okay, I dug a little deeper. #44 re-added the hunk, but in totally the wrong place. ;) No wonder it's failing. I'll re-roll properly. Stay tuned.

dww’s picture

Okay, that's better. The assertion in question is a stand-alone assertion and can't be mixed in with a new page get in the middle of all the filter group stuff the rest of this test case is doing. Moved it to the very top of testFilterCriteriaDialog(). This now passes locally. Bot should agree.

Also, at @Lendude's request in Slack, I'm removing the nids from the comments (#42.3). Confirmed that we don't (normally) do that and if folks want to find the nids, they can git blame.

Interdiffs relative to #38 and #44 for the interested reader.

Enjoy,
-Derek

The last submitted patch, 49: 2825446-49.test-only.patch, failed testing. View results

anavarre’s picture

Status: Needs review » Reviewed & tested by the community

🤦wrong copy paste, sorry!

Thanks for re-rolling this cleanly. Back to RTBC now that this was sorted out.

Lendude’s picture

RTBC++

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

  • webchick committed ba44244 on 8.8.x
    Issue #2825446 by Pancho, anavarre, michielnugter, dww, Lendude, dmsmidt...

  • webchick committed f53f404 on 8.7.x
    Issue #2825446 by Pancho, anavarre, michielnugter, dww, Lendude, dmsmidt...
webchick’s picture

Status: Reviewed & tested by the community » Fixed

Mmm. Love the taste of patches that are one-line fixes and bazillions of tests. ;)

Committed and pushed to 8.8, and since it's a major bug fix, also backported to 8.7. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

lauriii’s picture

Status: Closed (fixed) » Needs review
FileSize
723 bytes

This change should have been applied to the ES6 file, and then compiled. At the moment, whenever you compile JavaScript, this change gets reverted.

Lendude’s picture

Status: Needs review » Reviewed & tested by the community

Applied the patch, compiled JS, no other changes then the patched es6 file, so this checks out. Sorry for missing this!

dww’s picture

Good point! Whoops, we missed. #58 is indeed RTBC.

Thanks/sorry,
-Derek

  • webchick committed fdbee96 on 8.8.x
    Issue #2825446 follow-up by lauriii: Apply changes to ES6 files, too.’...

  • webchick committed 5e1068a on 8.7.x
    Issue #2825446 follow-up by lauriii: Apply changes to ES6 files, too.
    
    (...
webchick’s picture

Status: Reviewed & tested by the community » Fixed

Oopsie. :( Thanks for the fix!

Committed and pushed to 8.8.x and 8.7.x. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.