Problem/Motivation

In Views UI Advanced settings, Contextual Filters are placed above Relationships. The problem with this order is that some contextual filters (arguments) only show up if the user chooses a relationship first.

Views Advanced Settings current sequence

People tend to work top down, so imho some misconceptions about contextual filters and relationships could easily be avoided by changing the order of those items and listing relationships above contextual filters.

In others words, contextual filters may depend on relationships, so the latter ones should be listed first.

Steps to reproduce

1. Create a new view (/admin/structure/views/add). View settings (show: content, of type: article, sorted by: newest first). Page setting (create a page checkbox checked)
2. Within the advanced section click the add button for contextual filters
3. Enter "rol" into the search field => there are no contextual filters found
contextual filters modal showing no search results for the search term rol
4. Click the cancel button
5. Within the advanced section click the add button for Relationships
6. Enter "user" into the search field and select user for the content category and click the add and configure relationships. On the next screen in the modal just click apply.
7. Within the advanced section click the add button for contextual filters again
8. Enter "rol" into the search field => this time roles in the user category are found.
contextual filters modal showing the search result roles in the user category for the search term rol

Proposed resolution

Switch the position of the contextual filters and relationships

Remaining tasks

no remaining tasks

User interface changes

Before the patch is applied:
views advanced section with contextual filters before relationships
After the patch is applied:
views advanced section with relationships before contextual filters

API changes

No changes

Data model changes

No changes

Release notes snippet

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

drubb created an issue. See original summary.

drubb’s picture

Added a first simple patch to achieve the desired behaviour.

drubb’s picture

Issue summary: View changes
drubb’s picture

Issue summary: View changes
drubb’s picture

mattlc’s picture

Issue summary: View changes
FileSize
30.28 KB
43.78 KB

Hi,

Thank you for this patch.
This is OK for me. Code is simple and works as expected.

I tested it on a fresh install in "content" core view form.

Please see attached screenshots before and after.

Before

After

pguillard’s picture

Status: Needs review » Reviewed & tested by the community

OK for me too !

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Status: Reviewed & tested by the community » Needs work

Status: Reviewed & tested by the community » Needs work

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

drubb’s picture

Status: Needs work » Needs review
Issue tags: -DevDaysLisbon +@DevDaysTransylvania

Checked the patch is still valid for Drupal 8.8.x

pguillard’s picture

drubb’s picture

Status: Needs review » Reviewed & tested by the community

Status: Reviewed & tested by the community » Needs work
yogeshmpawar’s picture

Status: Needs work » Reviewed & tested by the community

Setting back to RTBC, above test fails are unrelated.

ckrina’s picture

Issue tags: -Needs usability review

contextual filters may depend on relationships, so the latter ones should be listed first.

+1 to this small but useful change on a UX perspective.

jrockowitz’s picture

Some thought/notes...

  • Contextual Filter are more commonly used than Relationships
  • Contextual Filters do not require Relationships
  • For many fields 'Relationships' are added in the background

I am not sure this change is worth making.

ckrina’s picture

Discussed today at UX meeting and I agree with @jrockowitz: I missed that Contextual Filters do not require Relationships. I was assuming one required the other.

And as Angie and Aaron suggested on the call, Contextual Filters is one of the most used features in the "Advanced" group and probably people with experience with this UI would get confused.

webchick’s picture

Yeah, one of our concerns was "muscle memory" since Contextual Filters is a 60-70% use case vs. Relationships more like 10-20%. Suddenly flipping them 10+ years into Views UI's lifetime could lead to frustration. I think not knowing that Views would "fill in the blanks" of missing relationships, this change would make a lot of sense. But since it seems to do that, this might be "won't fix" (sorry :\), at least unless the impact of not making the change can be demonstrated to override these other concerns.

It's a tricky problem because you're balancing "mental model" with "frequency of use" and both are valid ways to order listings of stuff. (As well as alphabetical, etc.)

webchick’s picture

Status: Reviewed & tested by the community » Needs review

Bumping back to needs review for more feedback.

drubb’s picture

I've added a simple example on why this is an issue, see attached screenshots:

Let's say we build a simple view to list content using the author's role as contextual filter. This is not possible without adding the 'user' relationship before choosing the contextual filter 'roles', the filter won't show up.

Without the "User" relationship:

Filter without relationship

After adding the "User" relationship:

Filter with relationship

This way, many users would just give up saying "ok, seems it's not possible to filter by roles, there's no filter obviously".

drubb’s picture

Issue summary: View changes

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

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

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

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.

smustgrave’s picture

So what's the final verdict? The patch does work and can see both sides for changing and not changing it.

Abhijith S’s picture

Applied patch #13 on 9.5.x and it works fine.

Before patch:
before

After patch:
after

smustgrave’s picture

Status: Needs review » Postponed (maintainer needs more info)

Thank you for testing but doesn’t answer the open question

drubb’s picture

Issue summary: View changes
drubb’s picture

Issue tags: +Needs usability review
rkoller’s picture

Issue summary: View changes
Status: Postponed (maintainer needs more info) » Needs review

I've updated the issue summary by adding steps how to reproduce the issue illustrated with the screenshots found in #22. I'll set the issue back to needs review so the requirements for a review in fridays usability meeting are met (either in #3308883: Drupal Usability Meeting 2022-09-16 or in one of the upcoming weeks). That issue is definitely a good fit for having a discussion there. The points brought up in #18 and #20 are definitely reasonable and valid but at the same time a case that options stay unnoticed by the user are reasonable and valid as well. so a solution to the problem should be discussed.

rkoller’s picture

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

We've discussed the issue at #3308883: Drupal Usability Meeting 2022-09-16. It will have a link to the recording and transcript of the meeting. For the record the attendees at the meeting were @aaronmchale, @benjifisher, @blackbamboo, @simohell, @worldlinemine, and me.

The group had a general consensus that there is the functional reason to have the change as described in the issue summary as well as the steps to reproduce section. In contrast to the comments in #18, #19, and #20 the experience of the attendees in personal as well as customer projects was the opposite, that relationships are used more often than contextual filters. Therefore a comment from @aaronmchale in the run-up to todays meeting sums up the case pretty well

I'm less convinced by the muscle memory argument, the first time the change happens and people see it, yeah they might click the wrong things once or twice, but their "muscle memory" will re-learn, you could apply that same argument to almost every change we make which causes a UI to be changed: someone, somewhere will have their "muscle memory" impacted for a brief moment. I don't think that's a good justification for not making an improvement, particularly when it comes to usability. If the change we make has an overall positive impact, then we should make that change.

As @benjifisher put it at the end "if there is a functional reason then let's do it". Therefore our recommendation is to switch the position of relationships and contextual filters as described in the issue summary. I'll remove the Needs usability review tag again and set the issue back to Needs work since it would need a patch for Drupal 10.1.x-dev at this point.

smustgrave’s picture

#13 still appears to apply to 9.5.x and 10.1.x. Queued up for retesting

This issue does not need anymore screenshots.

smustgrave’s picture

So #13 passed 10.1.x but had, what appears to be a random, failure on 9.5x

Should this go to review then for 10.1?

benjifisher’s picture

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

The beta releases for Drupal 9.5.0 and 10.0.0 were released yesterday. I think that means that most issues, including this one, should now target 10.1.x, so I am updating the version field.

I expect that issues will be bulk-updated soon to make the same change, like #24-#29 on this issue.

smustgrave’s picture

Status: Needs work » Needs review

So moving to NR since the patch passed 10.1

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

The change is very simple so I don’t mind marking RTBC.

Again no more screenshots

rkoller’s picture

Issue summary: View changes

According to a chat in the ux channel in the drupal slack i've updated the issue summary and adjusted it to the issue summary template. I've only left out the original report section since that one doesn't apply for this issue. I've then also added the screenshots from #31 to the ui changes section and added a sentence to the proposed resolution section.

AaronMcHale’s picture

+1 to RTBC from my perspective, let's get this one done!

alexpott’s picture

Version: 10.1.x-dev » 9.5.x-dev
Status: Reviewed & tested by the community » Fixed

Credited as many people as possible for the discussion. Committing the patch as this change was agreed by the Drupal usability meeting.

Committed and pushed 7f52db6fb2 to 10.1.x and e7e1cab8f7 to 10.0.x and 6c67f2b5e3 to 9.5.x. Thanks!

  • alexpott committed 7f52db6 on 10.1.x
    Issue #2975616 by drubb, pguillard, mattlc, rkoller, webchick, ckrina,...

  • alexpott committed e7e1cab on 10.0.x
    Issue #2975616 by drubb, pguillard, mattlc, rkoller, webchick, ckrina,...

  • alexpott committed 6c67f2b on 9.5.x
    Issue #2975616 by drubb, pguillard, mattlc, rkoller, webchick, ckrina,...

Status: Fixed » Closed (fixed)

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