Commit 450c9390 authored by catch's avatar catch
Browse files

fix: #3132725 "Limit list to selected items" on exposed filters does not filter

By: devad
By: dww
By: steyep
By: quietone
By: smustgrave
By: carlos romero
By: dcam
By: godotislate
By: acbramley
By: pameeela
(cherry picked from commit f867bed1)
parent 49cf73e0
Loading
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -320,8 +320,8 @@ public function acceptExposedInput($input) {

    // The "All" state for this type of filter could have a default value. If
    // this is a non-multiple and non-required option, then this filter will
    // participate by using the default settings if 'reduce' is true.
    if (empty($this->options['expose']['multiple']) && empty($this->options['expose']['required']) && !empty($this->options['expose']['reduce'])) {
    // participate by using the default settings *if* 'limit' is true.
    if (empty($this->options['expose']['multiple']) && empty($this->options['expose']['required']) && !empty($this->options['expose']['limit'])) {
      $identifier = $this->options['expose']['identifier'];
      if ($input[$identifier] == 'All') {
        return TRUE;
+0 −41
Original line number Diff line number Diff line
@@ -253,47 +253,6 @@ protected function getGroupedExposedFilters(): array {
    return $filters;
  }

  /**
   * Tests exposed filter with reduce as TRUE.
   */
  public function testFilterExposedReduce(): void {
    $view = Views::getView('test_view');
    $view->setDisplay();

    $view->displayHandlers->get('default')->overrideOption('filters', [
      'age' => [
        'id' => 'age',
        'field' => 'age',
        'table' => 'views_test_data',
        'value' => [25 => 25, 27 => 27],
        'operator' => 'in',
        'exposed' => TRUE,
        'expose' => [
          'operator' => 'age_op',
          'label' => 'age',
          'identifier' => 'age',
          'reduce' => TRUE,
        ],
      ],
    ]);

    $this->executeView($view);

    $expected_result = [
      [
        'name' => 'John',
        'age' => 25,
      ],
      [
        'name' => 'George',
        'age' => 27,
      ],
    ];

    $this->assertCount(2, $view->result);
    $this->assertIdenticalResultset($view, $expected_result, $this->columnMap);
  }

  /**
   * Tests that the InOperator filter can handle TranslatableMarkup.
   */