Views: Table click sorting does not use a defined sort plugin

Created on 1 October 2020, over 3 years ago
Updated 1 February 2024, 5 months ago

Problem/Motivation

As described here: https://drupal.stackexchange.com/questions/296711/custom-view-sort-plugi...

I defined a custom entity "committee_membership" with a field "committee_role". Each politician who is member of a committee has such an entity with a field which describes his/her role within the committee. The sorting by committee_role should be logical - I mean not numeric or alphabetical by key or value but logical in the sense that the chairperson should be listed first, then the vice chairperson, that the speaker and then the members.

We defined a custom views sort plugin which did this job quite well for views with no table display. When using this field in a table display view where the users can change the sorting by clicking the table headers the sorting was not done by the custom sort plugin. The sorting now was alphabetical by the values in the field / database table column.

Steps to reproduce

Please see https://drupal.stackexchange.com/questions/296711/custom-view-sort-plugi... for more details

Proposed resolution

When for a views field a sort plugin is defined Drupal\views\Plugin\views\field\EntityField->clickSort() and Drupal\views\Plugin\views\field\FieldPluginBase->clickSort() should use the logic from this sort plugin. By now this method is called when the click sorting is activated for a table display view and it implements a second sort logic not respecting any sort plugin which may be defined for the field.

Remaining tasks

User interface changes

No changes.

API changes

No API changes (?)

Data model changes

No data model changes.

Release notes snippet

✨ Feature request
Status

Active

Version

9.5

Component
ViewsΒ  β†’

Last updated 1 minute ago

Created by

πŸ‡©πŸ‡ͺGermany tobiberlin Berlin, Germany

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡¨πŸ‡¦Canada xmacinfo Canada

    Currently these two things are separate by design.

    Why are those two sorts separated by design? I would expect the same sort results for both.

Production build 0.69.0 2024