This very old issue is still here in D8.8.5.

There is a long D7 conversation about this issue, but since there is no D8 issue (or I couldn't find it) I decided to create one... as hope for resolve in D7 is fading.

To reproduce inside clean D8 installation:

  1. Create few articles and basic pages.
  2. Inside core Content view edit "Content type" filter.
  3. Select Article content type only and choose "Limit list to selected items".
  4. Visit /admin/content. Exposed filter contains only Article content types which is proper, but all content is returned in the view results list including basic pages.

Screenshot attached.

The behavior can be reproduced with any other exposed filter as well. Trying to limit Vocabulary exposed filter to certain Terms for example.

TEMPORARY SOLUTION: Adding another - not exposed content type filter - with Article content type selected only (which removes Basic Pages from view results list) is popular workaround all these years.

However, 11 years passed since this views issue is reported, and D9 is just around the corner... it would be nice to gift ourselves the fix. :)

CommentFileSizeAuthor
content-type-filter.jpg132.51 KBdevad

Issue fork drupal-3132725

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

devad created an issue. See original summary.

Ashutosh.tripathi’s picture

Status: Active » Reviewed & tested by the community

Hi @devad,

As the statement "Limit list to selected items" states that it should limit the items shown in the dropdown. It seems to be working fine as its properly filtering the dropdown. This checkbox "Limit list to selected items" only meant to limit the dropdown list not the result set as its an exposed filter and will act only when you select something. Hope this makes sense!

Thanks
Ashutosh

dww’s picture

Category: Bug report » Support request
Status: Reviewed & tested by the community » Closed (works as designed)

More accurate category and status.

Thanks,
-Derek

dww’s picture

p.s. If you don't want the '- Any -' choice (which is what's giving you grief), you have to set that exposed filter to be 'Required'. That's really the problem you're hitting...

devad’s picture

Thank you all for kind replies and help in understanding the real meaning of checkbox title and description.

Due to not so precise use of words in checkbox title and description for all drupalers who will come for the first time to this checkbox in the future - there will always be two ways how they can understand checkbox functionality.

So, I have opened separate issue as follow-up to this one... a small initiative to slightly alter checkbox description in order to make its meaning more precise and to avoid any further misunderstandings about its proper use.

Please, feel free to join: #3133906: "Limit list to selected items" checkbox - Title and description adjusting

steyep’s picture

Understanding that this is working as intended but the InOperator filter contains code that should limit the "all" filter to the selected items:

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;
  }
}

The related exposed filter form is assigning that value to reduce instead of limit:

$form['expose']['reduce'] = [
  '#type' => 'checkbox',
  '#title' => $this->t('Limit list to selected items'),
  '#description' => $this->t('If checked, the only items presented to the user will be the ones selected here.'),
  // Safety.
  '#default_value' => !empty($this->options['expose']['reduce']),
];

So, one possible work around would be to alter the value in a pre build hook:

/**
 * Implements hook_views_pre_build().
 */
function my_module_views_pre_build(ViewExecutable $view) {
  if ($view->id() === 'my_view_id') {
    $my_filter_id = 'my_filter_id';
    if (isset($view->filter[$my_filter_id]->options['expose']['reduce'])) {
      $view->filter[$my_filter_id]->options['expose']['limit'] = $view->filter[$my_filter_id]->options['expose']['reduce'];
    }
  }
}
devad’s picture

Status: Closed (works as designed) » Active
Issue tags: +Bug Smash Initiative

This bug (which has evolved into feature) is still around although Views joined the Drupal core many years ago.

Let's assign the "Bug smash initiative" to this issue and see if the Bug smash initiative team has will to deal with it.

It would be great to have Views cleaned up from this ugly 14 years old bug before D11 is released. :)

The issue below has a working D7 patch witch depicts nicely the original 'reduce' -> 'limit' typo-mistake which caused this bug to appear 14 years ago:

#1309578: When using operator "Is one of" and "Limit list to selected items" - 'Any' should not ignore the selected items.

I am willing to help with manual tests and feedbacks as much as I can.

devad’s picture

Additionally... it would be nice if we can make here the "Limit list to select items" option to work nicely with "Is not one of" operator as well... which is not the case currently... but of course, it can be done in the separate issue as well.

quietone’s picture

Version: 8.8.x-dev » 11.x-dev
Issue tags: -Bug Smash Initiative

Occasionally, I check the Drupal 8 issue queue and today was one of those days. Since Drupal 8 is no longer supported I am moving this to 11.x where it will be seen by the community. I am also removing the bug smash tag because that is added after the Bug Smash Initiative has triaged an issue.

Carlos Romero made their first commit to this issue’s fork.

Carlos Romero’s picture

Good morning everyone.

Comment #6 is right, I have tried what he says and he is right, thank you very much steyep.

I have created a fork branch and done mr to 10.2.x and 11.x.

Greetings to all.

Carlos Romero’s picture

Assigned: Unassigned » Carlos Romero
Status: Active » Needs review
smustgrave’s picture

Category: Support request » Bug report
Status: Needs review » Needs work
Issue tags: +Needs tests, +Needs issue summary update

Thanks for working on this old one.

Can the issue summary be updated using the standard issue template please

Changed to a bug as support requests typically don't have code fixes. But will need a test case showing the issue.