Problem/Motivation

Operator labels are not redrawn when a filter is removed on the rearrange filters UI. As a result, the last filter on the list will have a confusing operator label. After the filters are rearranged, the operator labels are regenerated resulting in the operator label being removed from the last item.

Steps to reproduce

  1. Go to /admin/structure/views/view/frontpage
  2. Click And/Or Rearrange on the filter criteria pane
  3. Rearrange the filters to make the operator labels visible
  4. Remove the last filter from the list

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Comments

lauriii created an issue. See original summary.

mirakolous’s picture

I have added a patch that fixes this issue. Although the redrawing function was run and filtering out hidden table rows, it was running before the table row was removed. Re-adjusting the order of these functions resolves this issue.

mirakolous’s picture

Status: Active » Needs review
mirakolous’s picture

See if this test passes

lauriii’s picture

Issue tags: +Needs tests

Thank you for working on this! I'm wondering if we have some pre-existing test coverage which we could extend easily to add coverage for this?

kndr’s picture

Issue tags: -Needs tests +Needs review
StatusFileSize
new144.19 KB
new1.6 KB
new5.63 KB

I found the pre-existing test coverage I made use of. I also realized this bug appears very early - right after clicking on 'Remove' at the last filter (look at the attached screencast) so there was no need to test rearranging filters with drag-and-drop. The #4 patch works for me so I extended it with the test only.

screencast

kndr’s picture

StatusFileSize
new1.6 KB

The interdiff for the record.

The last submitted patch, 6: views_ui-operator_labels-3161207-6-tests.patch, failed testing. View results

abhijith s’s picture

StatusFileSize
new790.87 KB

The patch #6 is working fine.The operator will be gone after removing last item.Including screen recording below after applying the patch:
record

RTBC

tanubansal’s picture

StatusFileSize
new289.61 KB

Tested #4 on 9.1. Its working fine
RTBC +1

lendude’s picture

Status: Needs review » Needs work
Issue tags: -Needs review

Nice work on this.

+++ b/core/modules/views_ui/tests/src/FunctionalJavascript/FilterCriteriaTest.php
@@ -125,6 +125,35 @@ class FilterCriteriaTest extends WebDriverTestBase {
+    // The current last filter shouldn't have the operator label.
+    $operator_label = $penultimate_row->find('css', '.views-operator-label');
+    $this->assertNull($operator_label, 'The last filter has no operator label.');

Can we add an assertion that the label is present before we remove the last row, that way we are actually testing for a change. Currently the test would also be green if the label was never there to begin with.

kndr’s picture

Status: Needs work » Needs review
Issue tags: +Needs review
StatusFileSize
new2.74 KB
new6.77 KB
new2.1 KB

You are right, Lendude. Here is the new test and the patch.

The last submitted patch, 12: views_ui-operator_labels-3161207-12-test.patch, failed testing. View results

Status: Needs review » Needs work

The last submitted patch, 12: views_ui-operator_labels-3161207-12.patch, failed testing. View results

kndr’s picture

Status: Needs work » Needs review

The test is green again.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

ranjith_kumar_k_u’s picture

StatusFileSize
new1.31 MB
new1.51 MB

The patch #12 is working fine on drupal 9.2.dev
before patch before patch
after patch after patch . RTBC

ranjith_kumar_k_u’s picture

StatusFileSize
new6.75 KB

Re-rolled for 9.2.x-dev

lendude’s picture

Status: Needs review » Needs work
Issue tags: -Needs review

@ranjith_kumar_k_u why reroll? It was applying fine to 9.2.x ¯\_(ツ)_/¯

Tests are looking great now. Bit of nitpicking:

  1. +++ b/core/modules/views_ui/tests/src/FunctionalJavascript/FilterCriteriaTest.php
    @@ -125,6 +125,56 @@ class FilterCriteriaTest extends WebDriverTestBase {
    +   * Issue: https://www.drupal.org/project/drupal/issues/3161207
    

    This isn't needed. People can just git blame

  2. +++ b/core/modules/views_ui/tests/src/FunctionalJavascript/FilterCriteriaTest.php
    @@ -125,6 +125,56 @@ class FilterCriteriaTest extends WebDriverTestBase {
    +    $assert_session = $this->assertSession();
    

    This isn't used

  3. +++ b/core/modules/views_ui/tests/src/FunctionalJavascript/FilterCriteriaTest.php
    @@ -125,6 +125,56 @@ class FilterCriteriaTest extends WebDriverTestBase {
    +    $last_row = $row[count($row) - 1];
    +    $penultimate_row = $row[count($row) - 2];
    

    Maybe just using array_pop() twice would make this a little easier to read? Dunno, this works to, but not that easy to read.

anmolgoyal74’s picture

Status: Needs work » Needs review
StatusFileSize
new6.63 KB
new1.53 KB

Addressed #19.

Status: Needs review » Needs work

The last submitted patch, 20: 3161207-20.patch, failed testing. View results

kndr’s picture

kndr’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work
kndr’s picture

StatusFileSize
new2.1 KB

Here is an interdiff I forgot to attach.

kndr’s picture

Status: Needs work » Needs review
Issue tags: +Bug Smash Initiative

I'm changing the status to "Needs review" because a "test-only" patch failed and it changed the status to "Needs work". A complete patch #22 is green and ready to review. The issue meets the requirements of Bug Smash Initiative so I added a relevant tag as well.

paulocs’s picture

Assigned: Unassigned » paulocs
paulocs’s picture

Assigned: paulocs » Unassigned
Status: Needs review » Reviewed & tested by the community
StatusFileSize
new694.69 KB

I reviewed patch #22 and it looks to me. It addresses what @Lendude pointed on comment #19.
Tests looks good and well documented.

I attached a gif to confirm that I tested the functionality and that it is working.

@kndr next time you can attach the test patch first and then the complete patch so issue status will not change to "needs work" (just a small tip ;) ).

lauriii’s picture

Version: 9.2.x-dev » 9.1.x-dev

Committed 22c3d04 and pushed to 9.2.x. Thanks!

Leaving open for backport to 9.1.x.

  • lauriii committed 22c3d04 on 9.2.x
    Issue #3161207 by kndr, Mirakolous, ranjith_kumar_k_u, anmolgoyal74,...

  • lauriii committed 76d1e6f on 9.1.x
    Issue #3161207 by kndr, Mirakolous, ranjith_kumar_k_u, anmolgoyal74,...
lauriii’s picture

Status: Reviewed & tested by the community » Fixed

Discussed with @alexpott and we agreed to backport this to 9.1.x.

Status: Fixed » Closed (fixed)

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