Problem/Motivation

This request is a natural follow-up of an existing D8 issue:
#3132725: "Limit list to selected items" on exposed filters does not filter
And D7 issue:
#510068: Using "Limit list to selected items" on exposed filters not working

The title and description of the checkbox: "Limit list to selected items" is not clear in that it only applies to the filter options and not the view results:
"If checked, the only items presented to the user will be the ones selected here."

A more precise checkbox description would mean less "Closed as designed" issues in the future.

Steps to reproduce

- Create/change a view;
- Add a 'filter criterion' to the view;
- Enable "Expose this filter to visitors, to allow them to change it" - the form will get expanded with additional options;
- Enable "Expose operator" (only to get a similar, other option "Limit the available operators" visible);
- Verify the text of the option "Limit list to selected items".

Proposed resolution

The title and description should be updated to clarify this.

Title: "Limit <em>filter</em> list to selected items"
Description: "If checked, the only <em>filter options</em> presented to the user will be the ones selected here. This checkbox has no effect on view results list."

And to clarify checkbox purpose completely, and to help those who need results of selected-items-only to be inside view-results-list as well - we could add some documentation words to description:

"If you need view results list to contain results of selected items only, please create additional (same, but non-exposed) filter."

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-3133906

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:

Comments

devad created an issue. See original summary.

devad’s picture

Issue summary: View changes
devad’s picture

Issue summary: View changes
devad’s picture

Issue summary: View changes
devad’s picture

Issue summary: View changes
klidifia’s picture

Status: Active » Needs review
StatusFileSize
new975 bytes

Certainly makes sense; I think it's more important to update the title to include the word filter, I've done both here.

klidifia’s picture

Issue summary: View changes
kristen pol’s picture

Thanks for the issue and patch.

Although I understand the motivation to create this issue and the patch works as expected, I'm note sure this wording change is necessary. It does make it more clear, but I'm not sure if updating the wording as suggested fixes the DX problem.

I agree with @dww here:

https://www.drupal.org/project/drupal/issues/3132725#comment-13593735

and if there is a wording change, maybe it should capture that. Something like:

If checked, the only filter options presented to the user will be the ones selected here. To ensure the results are also limited to this list, this filter must be required or an additional filter is necessary to filter the results.

I'm not sure that makes it more clear but you probably get the idea.

I did check the patch worked as expected as shown in this screenshot.

devad’s picture

Thanx for patch @klidifia

I agree that changing title as well is the best option.

I didn't want to suggest title change in the beginning since it is not completely necessary if checkbox description is good enough. But for those who read titles only... yeah... title change is more important. :)

devad’s picture

Regarding patch #6 ... did you purposely omit "This checkbox has no effect on view results list." at the end of description or accidentally?

I believe these few words are important to be included at the end of description if we want to avoid future misunderstandings of this checkbox purpose completely.

devad’s picture

Regarding more elaborated description for those who need result list to be filtered as well (as suggested in #8 and original text) maybe it would be better to add "Limit list to selected items" instructions to views exposed filters documentation page and to link description to that page.

We can create a new documentation page for that purpose if above page should not be used for such detailed instructions.

Currently there is no one word of description of "Limit list to selected items" checkbox in views exposed filters documentation page.

kristen pol’s picture

Status: Needs review » Needs work

IMO this should go back to "Needs work" so changing. See comment in #8.

kristen pol’s picture

@devad Looks like we crossposted. I didn't submit a patch, I only tested the patch. I don't have strong opinions on this issue but if the issue is that people don't know that the checkbox doesn't filter the results then additional text in the description and/or the documentation is necessary IMO.

devad’s picture

> I didn't submit a patch, I only tested the patch.

Yeah... we cross posted twice. I have corrected patch author promptly but not before your posts. :)

devad’s picture

> if the issue is that people don't know that the checkbox doesn't filter the results
> then additional text in the description and/or the documentation is necessary

Yeah... that's the main reason for this support request. Many drupalers are confused.

Some history... The original purpose of this checkbox was to filter both filter options and view results and thats why its title and description are ambiguous as they are now. The clear and very simple bug was discovered and patched 6 years ago, but never commited because the bug morphed into feature used by many web sites as nicely explained by @David_Rothstein here.

So, fixing the bug is not an option any more... but what we can do is to adjust title and description to describe the real purpose of this checkbox unambiguously.

devad’s picture

Title: "Limit list to selected items" checkbox - description adjusting » "Limit list to selected items" checkbox - Title and description adjusting
mrinalini9’s picture

Assigned: Unassigned » mrinalini9
mrinalini9’s picture

Assigned: mrinalini9 » Unassigned
Status: Needs work » Needs review
StatusFileSize
new1.09 KB
new902 bytes

Updated patch as per the changes mentioned in #8.

kristen pol’s picture

Status: Needs review » Needs work

Thanks for the update. I was thinking someone might improve upon my wording. :)

+++ b/core/modules/views/src/Plugin/views/filter/InOperator.php
@@ -88,7 +88,7 @@
+      '#description' => $this->t('If checked, the only filter options presented to the user will be the ones selected here. To ensure the results are also limited to this list, this filter must be required or an additional filter is necessary to filter the results.'),

Re-reading a few times, here's a slight modification:

If checked, the only filter options presented to the user will be the ones selected. To ensure the results are also limited to this list, this filter must be required or, alternatively, an additional filter must be added to filter the results.

But, I don't know if this is clear enough.

mrinalini9’s picture

Assigned: Unassigned » mrinalini9
mrinalini9’s picture

Assigned: mrinalini9 » Unassigned
Status: Needs work » Needs review
StatusFileSize
new1.1 KB
new1.03 KB

Updated patch as per the changes mentioned in #19.

kristen pol’s picture

Issue tags: +Needs manual testing

Thanks for the update.

1) Reviewed interdiff and it looks ok.

2) Tests are running so we'll wait on those.

3) Marked for manual testing.

devad’s picture

Limiting view results to selected options is not something everybody will need. So it would be nice to change wording to "If you need view results to be limited to selected options as well..."

New wording suggestion is here. I have marked all changes and additions:

If checked, the only filter options presented to the user will be the ones selected above. If you need view results to be limited to selected options as well - this filter must be required or, alternatively, an additional unexposed filter must be added to filter the results.

P.S.

For best DX, if possible, it would be nice to link words "additional unexposed filter" to Support article:

https://www.drupal.org/forum/support/post-installation/2012-02-29/limit-...

This would give developers direct link to helpful support article.

But I don't know if D8 field descriptions support html links...

mrinalini9’s picture

StatusFileSize
new1.35 KB
new1.29 KB

Hi @devad, I have updated the patch as per the changes suggested in #23, please review.

devad’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new88.87 KB

Thank you @mrinalini9

It looks good. Image attached. Marking as RTBC.

klidifia’s picture

Sorry yes I did intentionally leave out the "This checkbox has no effect on view results list." - I hadn't thought that is necessary as the view results list is effected when the user selects the option(s) that you permit them to select based on the selected items checkboxes and the "Limit filter list to selected items" checkbox.

But looking at that link you've included in the latest patch, I understand now and agree it's a worthy inclusion :)

kristen pol’s picture

Status: Reviewed & tested by the community » Needs work

Thanks for the update.

+++ b/core/modules/views/src/Plugin/views/filter/InOperator.php
@@ -87,8 +87,8 @@ public function buildExposeForm(&$form, FormStateInterface $form_state) {
+      '#title' => $this->t('Limit filter list to selected items'),
+      '#description' => $this->t('If checked, the only filter options presented to the user will be the ones selected above. If you need view results to be limited to selected options as well - this filter must be required or, alternatively, an <a href="@additional-unexposed-filter-support">additional unexposed filter</a> must be added to filter the results.', array('@additional-unexposed-filter-support' => 'https://www.drupal.org/forum/support/post-installation/2012-02-29/limit-list-to-selected-items-and-optional-on-views')),

We don't link core documentation to support posts so that will need to be removed.

Also, I would replace:

as well - this filter

with

as well, this filter

mrinalini9’s picture

Status: Needs work » Needs review
StatusFileSize
new1.13 KB
new1.32 KB

Hi @Kristen Pol, updated patch as per the changes mentioned in #27, please review.

devad’s picture

Re: #27

Sure. I had a doubt if linking to such external pages is allowed.

What about creating similar "additional unexposed filter" tutorial somewhere inside official documentation and linking to it. Is it possible?

I can volunteer to create such doc page with detailed instructions and screenshot images for beter DX. But I don't know what would be the best place to add such documentation page and if I have enough permissions to create/edit such document.

kristen pol’s picture

I don't think linking to any doc would be accepted by the core maintainers in this text change. If people are creating views, IMO they would likely know how to add an unexposed filter, especially since they are adding an exposed filter in this case.

devad’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new104.29 KB

Thank you for reply @Kristen Pol. I agree that this title and description should be enough.

And if not... there is alway Google search...

Tested patch #28. Looks good. Image attached. RTBC.

Thnx @mrinalini9 for all your patches and patience. :)

xjm’s picture

Category: Support request » Task
Status: Reviewed & tested by the community » Needs review
Issue tags: +Needs usability review

Thanks for working on this!

Let's request a usability review for this change, since that description is adding a lot of text and the more text there is, the less people read it. There are weekly meetings started from the #ux channel in Drupal Slack.

priyanka.sahni’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new234.08 KB
new192.76 KB
new115 KB

Verified and tested after applying the patch#28.It looks fine.The descriptive text would provide clarity to the users.

Steps to test-
1. Go to admin site
2. Go to /admin/structure/views/view/content
3. Verify the descriptive text appears under Limit filter list to selected items

Patch#28

After Patch

Before_Patch

xjm’s picture

Status: Reviewed & tested by the community » Needs review

Thanks @priyanka.sahni. As mentioned in #32, this needs a usability review. We've gone to lengths to shorten or eliminate descriptions wherever possible because it is better UX and more accessible. So setting NR until we get review from our usability team. As I suggested, one can ask about it in the #ux channel in Drupal Slack. There will be a meeting later today.

devad’s picture

On second thought... maybe we can make title and description a bit better and more compact with some changes:

Title: "Limit filter options..." is a bit more precise wording than "Limit filter list...". Especially if we want to make description shorter also.

Description: We could remove "If checked, the only filter options presented to the user will be the ones selected above." completely from description because there is no big reason to repeat again pretty much the same thing title is saying. Especially if we have additional points to stress inside description area.

-------------

After making the changes listed above and with few more wording improvements - the final result would be something like:

Title: "Limit filter options to items selected above"

Description: "If this filter is not required and you need view results to be limited also, please add an additional unexposed filter with same items selected."

-------------

This kind of wording could pass usability review easier I suppose - just a few words longer then current title and description, but much more straightforward and DX friendly.

Additional ideas, and wording improvements are welcome... since English is not my mother language...

shaal’s picture

We discussed this issue during Usability Meeting (see recording here #3150296: Drupal Usability Meeting 2020-06-16, from the beginning, conclusion at 13:00 minutes of that recording)

If I remember correctly, the last comment (#35) was what we agreed on + @webchik said she'll help fixing the wording of the sentence suggested there.

shaal’s picture

Status: Needs review » Needs work
devad’s picture

Thank you for discussing this topic during Usability Meetings.

Since this issue is back to "Needs work" status let me add a bit more of brainstorm to this issue.

The perfect solution for this issue could be to add one more checkbox as child checkbox below current "Limit list to selected items" checkbox. @David_Rothstein mentioned such solution here long time ago: #1309578-10: When using operator "Is one of" and "Limit list to selected items" - 'Any' should not ignore the selected items.

The title of the new checkbox could be "Limit view results to selected items also".

Ideally, the new checkbox could be Javascript hidden by default and we can make it visible only if both of these two criteria are fulfilled:

1."Limit list to selected items" checkbox is selected and
2. The exposed filter is not required ("Required" checkbox is not selected)

This would spare Developers from having to add one more filter and solve the performance issues caused by filter duplicates also.

If there are just a few items selected performance impact is not significant. But if there are many items selected - duplicate filters produce slow DB queries with many table joins. In some cases joins can grow out of allowed SQL limits (or execution time or memory limits) as described here:

#510068-26: Using "Limit list to selected items" on exposed filters not working

Adding new checkbox would be the best and the most complete DX friendly solution for this issue.

And if it is not possible or would be an overkill - we can go back to improving title and description of course.

kristen pol’s picture

I like @devad's suggestion in #38 unless there isn't a compelling reason for allowing the options to be filtered and not the results, i.e. if 99% of developers would expect that the results should be filtered when the options are filtered, then IMO it would make sense to just do it by default and not add another checkbox. Personally, I would keep the two in sync.

Could we get a sense if if either approach would be an acceptable change by the core maintainers?

devad’s picture

Re: @Kristen Pol #39

If "Limit list to selected items" checkbox is not selected then view results are filtered to selected items as expected.

If "Limit list to selected items" checkbox is selected then the view results become unfiltered suddenly.

Yes, it is a strange buggy behaviour indeed but there are backwards compatibility concerns connected with this clear typo bug.

With D8/9/10 flexibility maybe there is some handy way to "depricate" this bug in D9 and fix it properly in D10 with warnings to users that the checkbox functionality is fixed back to normal in D10 and that they should update their outdated views manually to match new functionality.

Only the views which have filter(s) which match all of the the following four criteria will need manual updates:

1. The filter is exposed
2. It is not required
3. "Limit list to selected items" checkbox is selected
4. Additional unexposed filter with same items selected is not added

Adding an additional unexposed filter with same items selected is a common developers' workaround for this bug last 10 years. So, most of the views which have first 3 criteria fulfilled have such unexposed filters added also. If such filter is not added that would mean that the user is using the checkbox's bug as a feature. Such views are easy to be recognised by update script and users can be warned that such outdated filters need to be manually updated after the D10 upgrade (or even earlier during some D9 minor upgrade if possible).

I do not expect that there will be a lot of views which will need such manual updates... if any... because to limit filter options and not to limit view results is not a common feature you need. If some users will need such a specific feature after D10 upgrade they can implement it back into their views with custom hooks.

kristen pol’s picture

Deprecating is an interesting idea but I'm not sure how it can be deprecated.

Normally with deprecation, the old method/approach is still supported while the new method/approach is in place. But in this case the old and new methods/approaches are actually *different*. Meaning, if someone *wanted* to have the options filtered but *not* the results then there isn't a way to both keep that and update the functionality to filter both options and results.

I don't see how to change it while still make it technically "backwards-compatible". So, it appears it can only be "fixed" (by filtering both the options/results) in Drupal 10 while in Drupal 9 we can only update the text.

Also, if it was fixed in Drupal 10, I don't think we should add code that notifies them that they can remove their extra filter. There can be a change record that explains it though.

devad’s picture

Changing title and description now, and fixing bug in D10 would be nice.

However, backwards compatibility after D10 upgrade will not be preserved.
If it is acceptable and adding D10 change record is enough - then straight fix would be the simplest solution.

The patch exists in D7 issue already and could be adjusted for D10 easy I suppose.

Technically... is it the last long-supported D9 version which should be fixed? Because The last D9 version and D10.0.0 should be (almost) identical... as much as I understand new versioning policy.

devad’s picture

Back to the roots of this issue...

As mentioned in #36... is it possible to assign this issue to @webchik and to commit title and description adjusting before 9.1 is out?

And for ideas introduced from #38 above we can open new issue if there is interest for further improvements before D10 is out.

devad’s picture

Just a reminder...

Is it possible to include this title and description change into D9.1?

Time is ticking... D9.1 alpha will come out in one week. :)

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.

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

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

johnv’s picture

Title: "Limit list to selected items" checkbox - Title and description adjusting » Change unclear Exposed filter option "Limit list to selected items" title and description
johnv’s picture

Component: views.module » views_ui.module
Issue summary: View changes
Status: Needs work » Needs review
StatusFileSize
new1.92 KB
new59.75 KB
new37.39 KB

As a summary of the above discussion:
#1-#34 are about the new text proposal
#28 contains the latest text proposal
#39-#44 are about other proposal that better deserves its own issue, if still needed.

#40 expresses some thoughts about current behaviour
I tested in D11.1 the behaviour of the (exposed) filter operators and options: Whatever the limit/expose settings, the values that are set in 'Filter criterion' form, are directly applied to the view, when a user calls the view.
[EDIT: This was tested with a computed field. #3132725: "Limit list to selected items" on exposed filters does not filter shows that the filter is applied when not exposed, but not when exposed - I regard this as an error.]

Issue summary is updated to standard format.
Issue moved to views_ui.module.

Regarding the text proposal, I find the additional lines hard to understand. Or even: I do not understand them at all.

As an alternative, let us compare with the other option:
[ ] "Limit the available operators" = "Limit the available operators to be shown on the exposed filter."
Then 'our' option would just be:
[ ] "Limit the available options" = "Limit the available options to be shown on the exposed filter to the ones selected above."
This is what is proposed in attached patch.

vladimiraus made their first commit to this issue’s fork.

smustgrave’s picture

Just FYI UI changes should include screenshots in the summary.

devad’s picture

Re: #51-#54

Thank you for trying to help. However, cosmetic change of title and description is not what this issue is meant for originally . The new description should warn users of existing bug behavior. Please read previous conversation in this issue. Comment #40 in particular (for bug information) but other comments as well.

smustgrave’s picture

Status: Needs review » Needs work

yea seems like there was still some discussion going on, didn't read the comments yesterday hence never changed the status.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

devad’s picture

The #3132725: "Limit list to selected items" on exposed filters does not filter is committed.

So, I suppose that this issue can be closed as outdated now since it is not needed any more.

smustgrave’s picture

Status: Needs work » Closed (outdated)

Thanks for flagging, agree we can close.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.