Closed (fixed)
Project:
Flag
Version:
5.x-dev
Component:
Views integration
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
8 Feb 2018 at 09:29 UTC
Updated:
27 Dec 2025 at 08:14 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
oleksiyComment #3
andypostSuch kind of bugs are testable
Comment #4
joachim commentedHuh?
Why would click-sorting this sort by user ID? I don't see how this makes sense.
This field is not data; it's function. Not being able to sort on it is correct.
Comment #5
oleksiyI have the following using case, where there is a need to sort Checked\Unchecked content. Also, this field is used to change content state.

The user ID is also defined in "Flagged" field (https://cgit.drupalcode.org/flag/tree/src/FlaggingViewsData.php?h=8.x-4....), which is used to show whether the flag is set or not. This is what I need for Link field to make it sortable. I think any column from the "flagging" table can be used for this purpose since the flag exists only if the record is present in the "flagging" table.
Comment #6
joachim commented> I have the following using case, where there is a need to sort Checked\Unchecked content. Also, this field is used to change content state.
Don't we have a flag status field which could be sorted on?
I can see that in your case you've made the flag link texts look like descriptions rather than actions, but for most people's setup, it won't make sense to sort on 'Flag this item'.
Comment #7
oleksiyWe have "Flagged" field which can be used for the sorting.
I got your point. I have attached another patch where only my specific case is handled. For most people's setup, this field will be the function, not data. The "clickSort()" will be executed only if someone enables click sorting for the field, so they will get sorted content insted of the error.
Comment #9
oleksiyTests added.
Comment #11
andypostVery probably it fails because of related issue
Comment #12
socketwench commentedHm. I'm not sure it is. I had the same error on #2955701: Add method to get flag in ConfirmFormBase but a retest made it vanish...
Comment #13
andypostYes, it looks like some random fail https://www.drupal.org/pift-ci-job/929080
Very probably kinda "wait-for-ajax" used cos failed only Ajax tests
Comment #14
socketwench commentedCreated #2957888: Ajax Tests randomly fail.
Comment #15
oleksiyTests were passed.
Comment #16
morbus iffI need this as well; my flags are "just" checkboxes (or, rather: FontAwesome square/check-squares) in a table, and I want to be able to visually sort by checked or unchecked. Screenshot attached.
Comment #17
morbus iffThis patch is working great for me.
I'm gonna set this to RTBC, given:
Comment #18
berdirAgree that the uid sort seems a bit weird, but indeed similar to what the other definition does. That said, I'd also be fine with the initial fix, it's consistent then. But no deal breaker.
What is one, unfortunately, is that this needs some updates to be D9 compatible, can't commit a patch that isn't anymore. Hopefully not too much work, new base class, default theme, D9 compatibility in the test module...
Comment #19
cecrs commentedJust wanted to add a comment, I had the same use case as @Oleksiy, where I needed the functional flag/unflag link in the view, but wanted to sort by whether they were flagged or unflagged. I was able to solve it by adding both 'Flagging' and 'Flagged' to my view, rewriting 'Flagged' as 'Flagging', and making 'Flagged' sortable in the table. (And excluding 'Flagging' from display)
Flagging/unflagging links work, and the view sorts correctly.
Comment #20
ivnishComment #23
mahima_mathur23 commentedResolved all PHPCS Issues
Comment #24
ivnishComment #26
deaom commentedRebased branch and updated the test. Changing status to needs review as I did not manually test it, but tests are passing.
Comment #27
ivnishNeeds check why it failed https://git.drupalcode.org/issue/flag-2943153/-/jobs/7076733#L55
Comment #28
deaom commentedFailed because the older version of phpstan does not have that method it seems. Replaced the method with the waitForElementRemoved as there is no actual element to check on ajax complete and that method also seems to not be available. As I did not want to complicate things added that specific error message to the phpstan.neon to be ignored and that also fails (as the issue is just with previous version). Open to suggestions as locally can't really reproduce. My POV, it's not a big deal, as it's only test and a previous version, so would leave as is.
Comment #30
ivnish