I have a view with exposed sorts but no exposed filters, enabling ctools_views hides these sorts completely.

This is because in Drupal\ctools_views\Plugin\Display\Block we have:

  /**
   * {@inheritdoc}
   */
  public function usesExposed() {
    $filters = $this->getHandlers('filter');
    foreach ($filters as $filter_name => $filter) {
      if ($filter->isExposed() && !empty($filter->exposedInfo())) {
        return TRUE;
      }
    }
    return FALSE;
  }

Which does not check for sort handlers at all. I don't see a reason for this function override as the DisplayPluginBase class does a similar job but checks all handlers (filters, pagers, sorts).

Comments

acbramley created an issue. See original summary.

acbramley’s picture

Status: Active » Needs review
StatusFileSize
new860 bytes

Here's a patch which removes the function so it defaults to core's Block display logic.

Status: Needs review » Needs work

The last submitted patch, 2: 2878418-ctools-views-exposed-2.patch, failed testing.

acbramley’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
StatusFileSize
new1.54 KB
new713 bytes

Can't reproduce this failure locally, although I get another error:

Fatal error: Uncaught Error: Call to a member function getPlugin() on null in /vagrant/app/modules/contrib/ctools/modules/ctools_views/src/Tests/CToolsViewsBasicViewBlockTest.php on line 301

Error: Call to a member function getPlugin() on null in /vagrant/app/modules/contrib/ctools/modules/ctools_views/src/Tests/CToolsViewsBasicViewBlockTest.php on line 301

Call Stack:
    0.0067     570816   1. {main}() /vagrant/app/core/scripts/run-tests.sh:0
    3.0839   17618896   2. simpletest_script_run_one_test(???, ???) /vagrant/app/core/scripts/run-tests.sh:66
    3.1041   18725048   3. Drupal\simpletest\TestBase->run(???) /vagrant/app/core/scripts/run-tests.sh:792
   47.8196   73669864   4. Drupal\ctools_views\Tests\CToolsViewsBasicViewBlockTest->testDisableFilters() /vagrant/app/core/modules/simpletest/src/TestBase.php:958

I believe the failure will be due to ajax being off on the block.

Status: Needs review » Needs work

The last submitted patch, 4: 2878418-ctools-views-exposed-4.patch, failed testing.

acbramley’s picture

Debugging into these tests I'm not sure how they pass at all on DrupalCI.

Inspecting the raw HTML output in testDisableFilters() after the post to add the filter block to the page shows no form output whatsoever. The assertions like $this->assertFieldByXPath('//select[@name="status"]'); return a false positive in that the field can't be found, but there's no $value passed in so it skips the entire part of assertFieldsByValue and just && together an empty array and $found (which defaults to TRUE) so passes.

erutan’s picture

I just ran into this, and stumbled onto ctools views as the culprit by process of elimination by nuking contrib. This feels like more than a "normal" priority issue honestly, though perhaps I'm the only one in 5 years that has tried to expose sort criteria without filters?

https://drupal.stackexchange.com/questions/310939/any-idea-why-exposed-s...

https://drupal.slack.com/archives/C6SQM2J94/p1651443238891589

erutan’s picture

Priority: Normal » Major