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.
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
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.
Proposed resolution
Switch the position of the contextual filters
and relationships
Remaining tasks
no remaining tasks
User interface changes
Before the patch is applied:
After the patch is applied:
API changes
No changes
Data model changes
No changes
Release notes snippet
Comment | File | Size | Author |
---|---|---|---|
#31 | 2975616-after_patch.png | 24.3 KB | Abhijith S |
#31 | 2975616-before_patch.png | 18.44 KB | Abhijith S |
#22 | filter-with-relationship.png | 26.47 KB | drubb |
#22 | filter-without-relationship.png | 12.42 KB | drubb |
#13 | move-relationships-above-contextual-filters-2975616-13.patch | 917 bytes | pguillard |
|
Comments
Comment #2
drubbAdded a first simple patch to achieve the desired behaviour.
Comment #3
drubbComment #4
drubbComment #5
drubbComment #6
mattlc CreditAttribution: mattlc commentedHi,
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
Comment #7
pguillard CreditAttribution: pguillard commentedOK for me too !
Comment #12
drubbChecked the patch is still valid for Drupal 8.8.x
Comment #13
pguillard CreditAttribution: pguillard commentedPatch rerolled
Comment #14
drubbComment #16
yogeshmpawarSetting back to RTBC, above test fails are unrelated.
Comment #17
ckrina+1 to this small but useful change on a UX perspective.
Comment #18
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedSome thought/notes...
I am not sure this change is worth making.
Comment #19
ckrinaDiscussed 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.
Comment #20
webchickYeah, 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.)
Comment #21
webchickBumping back to needs review for more feedback.
Comment #22
drubbI'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:
After adding the "User" 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".
Comment #23
drubbComment #30
smustgrave CreditAttribution: smustgrave at Mobomo commentedSo what's the final verdict? The patch does work and can see both sides for changing and not changing it.
Comment #31
Abhijith S CreditAttribution: Abhijith S as a volunteer and at Zyxware Technologies commentedApplied patch #13 on 9.5.x and it works fine.
Before patch:
After patch:
Comment #32
smustgrave CreditAttribution: smustgrave at Mobomo commentedThank you for testing but doesn’t answer the open question
Comment #33
drubbComment #34
drubbComment #35
rkollerI'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.Comment #36
rkollerWe'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 wellAs @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
andcontextual filters
as described in the issue summary. I'll remove theNeeds usability review tag
again and set the issue back toNeeds work
since it would need a patch for Drupal 10.1.x-dev at this point.Comment #37
smustgrave CreditAttribution: smustgrave at Mobomo commented#13 still appears to apply to 9.5.x and 10.1.x. Queued up for retesting
This issue does not need anymore screenshots.
Comment #38
smustgrave CreditAttribution: smustgrave at Mobomo commentedSo #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?
Comment #39
benjifisherThe 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.
Comment #40
smustgrave CreditAttribution: smustgrave at Mobomo commentedSo moving to NR since the patch passed 10.1
Comment #41
smustgrave CreditAttribution: smustgrave at Mobomo commentedThe change is very simple so I don’t mind marking RTBC.
Again no more screenshots
Comment #42
rkollerAccording 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.
Comment #43
AaronMcHale+1 to RTBC from my perspective, let's get this one done!
Comment #44
alexpottCredited 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!