Problem/Motivation
It seems when changing weights on /admin/config/search/search-api/index/[index_id]/sorts_widget/[sort_id] it is not respected when form is being rendered.
I'll provide a quick patch for that.
Also, the weights are not used in the admin table. It was sorting $sorts but rendering the $fields array, so the visual order didn't update.
Steps to reproduce
Proposed resolution
Make the rows follow the correct weights in the search page, and admin page.
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | search_api_sorts_widget-sort_weight-3488348-2.patch | 704 bytes | ludo.r |
Issue fork search_api_sorts_widget-3488348
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
ludo.rAnd here's the patch.
Comment #5
ressaThanks @ludo.r your patch makes the sort take effect! Though I don't see the tabledraggers (
tabledrag-cell's are set todisplay: none) ... I need to use the "Show row weights" option, and enter for example "-1" to get a field at the top. Do you see them?I created an MR, since that's probably better for the further process. Perhaps we should try to restore the tabledraggers in this issue as well ... what do you think?
Comment #6
ressaComment #8
peri22 commentedI have rebased MR !6 onto 1.x and added a second commit.
I tested ludo.r's fix, and it works perfectly: the widget now correctly follows the saved weights (-5/0/5).
My second commit fixes a similar issue in the admin table. It was sorting `$sorts` but rendering the `$fields` array, so the visual order didn't update. This is now fixed, and the rows follow the correct weights.
@ressa, about the missing drag handles: I think this is caused by the core "Show row weights" setting. When this is active, Drupal hides the drag handles in the browser. Could you check if you see the same behavior on other draggable tables (like Manage fields)? The tabledrag library is definitely attached correctly on our page.
Comment #9
peri22 commentedComment #10
ressaThanks for looking at this @peri22, your patch works perfectly, and the weight is taking effect both on the search page, and even also on the admin page. So this is ready :)
About the missing drag-icons, it seems to not be related to this issue, because I now see that they are missing under "Sorts widget", but also under "Sorts". But they are present under for example "Processors", so something strange is going on ... I'll try to dig some more to understand why it's happening.
Comment #11
peri22 commentedComment #13
peri22 commentedThanks for the review, @ressa! The MR is merged.
If you have time, could you also review #3267604: Base path duplicated for sites hosted in sub-directories (MR !9)? It is a small fix with a unit test.
Comment #14
ressaPerfect @peri22, thanks for landing this issue!
I would love to help with the other issue, but I am not sure how to quickly set this up in DDEV, where Drupal is served out of a subfolder ...
Comment #15
ressa@peri22 There are quite a few improvements since the latest version from December 2024, so perhaps a fresh release could be considered? I do understand if you prefer to wait the fourteen days, before the issue is automatically permanently Closed (fixed).
Another improvement I thought of for this module would be if it got security coverage and I created #3619631: Opt Search API Sorts Widget into Drupal’s security advisory policy.