Views exposed sort identifiers are not configurable when also exposed

Created on 11 December 2024, about 2 months ago

Problem/Motivation

In ✨ Views exposed sort identifiers are not configurable Fixed , the exposed sort identifiers were made configurable in the same way as the exposed filters identifiers.

But if the sort is exposed, this "meta" sorting options are not configurable. They will always be sort_by and sort_order.

This is an issue if you have several views in the same page exposing different sort filters, as this will show "The submitted value changed in the Sort by element is not allowed." unless you have the same filter ids in both.

Proposed resolution

Allow the exposed sort identifiers when exposed to be configured, having sort_by and sort_order by default.

Remaining tasks

MR with tests.

User interface changes

New, when sorting is exposed show in the exposed sort configuration subform the id for the sort_by and sort_order ids.

API changes

TBD

Data model changes

Config schema change. Will require upgrade path.

Release notes snippet

When exposing the sort options in the exposed form, the site builder is able to configure the identifiers that are exposed in the URL as query parameter values.

✨ Feature request
Status

Active

Version

11.0 πŸ”₯

Component

views.module

Created by

πŸ‡ͺπŸ‡ΈSpain penyaskito Seville πŸ’ƒ, Spain πŸ‡ͺπŸ‡Έ, UTC+2 πŸ‡ͺπŸ‡Ί

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

Merge Requests

Comments & Activities

  • Issue created by @penyaskito
  • Pipeline finished with Failed
    about 2 months ago
    Total: 123s
    #365992
  • πŸ‡ͺπŸ‡ΈSpain penyaskito Seville πŸ’ƒ, Spain πŸ‡ͺπŸ‡Έ, UTC+2 πŸ‡ͺπŸ‡Ί

    This:

    - needs tests
    - need upgrade path tests.
    - needs updating provided views in all profiles (and recipes?).

    Otherwise might be ready. Marking Needs review for getting feedback before working in tests.

  • Pipeline finished with Success
    about 2 months ago
    #365996
  • πŸ‡³πŸ‡±Netherlands Lendude Amsterdam

    I think the feature makes sense and is probably much harder to do in contrib than adding it to core since this stuff isn't exposed in any sort of hook.

    I'm not sold on the names and descriptions used here. I'd use 'key' and not 'id' to describe these, but even than it's still pretty hard to grasp what these are for. Since this is some pretty specialised config, we need strong descriptions to make clear what these are for I feel.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Thanks @lendude seems like solid feedback.

  • Pipeline finished with Canceled
    about 1 month ago
    Total: 93s
    #376675
  • πŸ‡ͺπŸ‡ΈSpain penyaskito Seville πŸ’ƒ, Spain πŸ‡ͺπŸ‡Έ, UTC+2 πŸ‡ͺπŸ‡Ί

    @lendude Given this manifested as an error message, I was tempted to mark this even as a bug instead of Feature request.

    Naming these are hard. In the meantime I used suffix as you suggested.
    The descriptions definitely need work.

  • Pipeline finished with Failed
    about 1 month ago
    Total: 722s
    #376676
  • Pipeline finished with Failed
    about 1 month ago
    Total: 130s
    #377993
  • Pipeline finished with Failed
    about 1 month ago
    Total: 130s
    #378018
  • Pipeline finished with Failed
    about 1 month ago
    Total: 525s
    #378024
  • Pipeline finished with Canceled
    about 1 month ago
    Total: 384s
    #378041
  • Pipeline finished with Failed
    about 1 month ago
    Total: 722s
    #378044
  • πŸ‡ͺπŸ‡ΈSpain penyaskito Seville πŸ’ƒ, Spain πŸ‡ͺπŸ‡Έ, UTC+2 πŸ‡ͺπŸ‡Ί

    This now contains tests, including for the views upgrade.

  • Pipeline finished with Success
    about 1 month ago
    Total: 936s
    #378057
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Looks super close. Left 2 more comments on the MR.

  • πŸ‡ͺπŸ‡ΈSpain penyaskito Seville πŸ’ƒ, Spain πŸ‡ͺπŸ‡Έ, UTC+2 πŸ‡ͺπŸ‡Ί

    Fixed config schema validation.

  • Pipeline finished with Failed
    about 1 month ago
    Total: 616s
    #379261
  • Pipeline finished with Success
    about 1 month ago
    Total: 1687s
    #379266
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Thanks feedback appears to be addressed

  • πŸ‡ͺπŸ‡ΈSpain plopesc Valladolid

    Feature makes sense and coed looks great.

    It seems that there are a couple of scenarios that should be taken into account during validation, though:

    • expose_sort_key & sort_order_key needs to be unique, as it happens with exposed form identifiers.
    • Collisions with exposed form identifiers need to be avoided as well

    Otherwise, the exposed form merges the 2 different form elements into a single one, having unexpected results and validation errors when loading the form.

    In the screenshot below, the Content view was modified, setting the same value for both expose_sort_key & sort_order_key. Only one of the dropdowns is rendered, and failing validation.

    Something similar happens if any of the exposed filters identifiers is used for any of the new options (langcode or type for the Content view).

    Might be necessary to extend DisplayPluginBase::isIdentifierUnique() to cover this scenario and pull it up to PluginBase

Production build 0.71.5 2024