[PR #4828] #4584 sort options for narrators #4355

Open
opened 2026-04-25 00:19:24 +02:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/advplyr/audiobookshelf/pull/4828
Author: @S-Reinhard
Created: 11/13/2025
Status: 🔄 Open

Base: masterHead: #4584-sort-options-for-narrators


📝 Commits (6)

  • 4f33de1 added sorting narators by name and book count
  • 0a963b4 Merge branch 'advplyr:master' into #4584-sort-options-for-narrators
  • 60624ec Merge branch 'advplyr:master' into #4584-sort-options-for-narrators
  • 2793b54 Merge branch 'advplyr:master' into #4584-sort-options-for-narrators
  • 5148502 implemented server side sort
  • f688bea Merge branch 'advplyr:master' into #4584-sort-options-for-narrators

📊 Changes

2 files changed (+37 additions, -5 deletions)

View changed files

📝 client/pages/library/_library/narrators.vue (+30 -4)
📝 server/controllers/LibraryController.js (+7 -1)

📄 Description

Brief summary

Allow users to sort narrators by name and book count.

Which issue is fixed?

Fixes https://github.com/advplyr/audiobookshelf/issues/4584

In-Depth Description

How the narrator sorting works:

Users can sort narrators by clicking on the corresponding table header cells.
When hovering over these cells, the cursor changes to a pointer. Because there are no lines separating the tabel cells, the text in the corresponding cell is underlined.
Clicking the same header again toggles the sorting direction (ascending/descending).
An arrow icon visually indicates the current sorting direction and only appears in the active column to show which column is being sorted.

To ensure the visual indicators and sorting logic remain in sync, both are driven by shared state properties like the currently selected attribute and sort order.

Those parameters are used as query params when fetching the narrators.
On the server side the query params from the request are replaced with known strings to ensure working default and fallback sorting options, before sorting the list of narrators using naturalSort().

Why this solution is effective:

It follows the design principle of external consistency—the behavior and appearance mimic commonly used sortable tables, making the feature intuitive and familiar for users.

Server side sorting will work in the future even when paging is added.

Areas for Improvement:

The current implementation uses a Unicode arrow character returned from a function. This wasn't my first choice; I would have preferred using an icon to support aria-labels. However, I was unable to insert a standalone icon without also introducing a button. If icon-based implementation is preferred, I would appreciate guidance on the icon library and documentation used in this project, along with relevant code examples.

Fetching a new list of narrators every time the order changes is a bit slow and creates unnecessary traffic, this could be improved by caching.

Who is affected:

While the change is small, it affects many users because it adds function to the web client.

How Have You Tested This?

I ran the project inside a dev container.
Then I added sample audiobooks as test data and navigated to the narrator page in a web browser. I verified the behavior when hovering over, clicking, and repeatedly interacting with the header cells of sortable columns.

Additionally, I confirmed that the edit and delete buttons next to each narrator still function as expected.

Screenshots

Before:
image
After:
image


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/advplyr/audiobookshelf/pull/4828 **Author:** [@S-Reinhard](https://github.com/S-Reinhard) **Created:** 11/13/2025 **Status:** 🔄 Open **Base:** `master` ← **Head:** `#4584-sort-options-for-narrators` --- ### 📝 Commits (6) - [`4f33de1`](https://github.com/advplyr/audiobookshelf/commit/4f33de1257a09dfb97042eb4fabe939a2cb8d69d) added sorting narators by name and book count - [`0a963b4`](https://github.com/advplyr/audiobookshelf/commit/0a963b4abcbfab60d744c1fd1e6914b0dbaa822b) Merge branch 'advplyr:master' into #4584-sort-options-for-narrators - [`60624ec`](https://github.com/advplyr/audiobookshelf/commit/60624ecff2bc054aeec140610e0d883543d49840) Merge branch 'advplyr:master' into #4584-sort-options-for-narrators - [`2793b54`](https://github.com/advplyr/audiobookshelf/commit/2793b54b5bb754051f0af411853f71d3a9f0c2fd) Merge branch 'advplyr:master' into #4584-sort-options-for-narrators - [`5148502`](https://github.com/advplyr/audiobookshelf/commit/5148502da78cb251bb1a4eddddc78301d2180a67) implemented server side sort - [`f688bea`](https://github.com/advplyr/audiobookshelf/commit/f688beae54fba5953bf7b6ca09204f8e671b59ec) Merge branch 'advplyr:master' into #4584-sort-options-for-narrators ### 📊 Changes **2 files changed** (+37 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `client/pages/library/_library/narrators.vue` (+30 -4) 📝 `server/controllers/LibraryController.js` (+7 -1) </details> ### 📄 Description <!-- For Work In Progress Pull Requests, please use the Draft PR feature, see https://github.blog/2019-02-14-introducing-draft-pull-requests/ for further details. If you do not follow this template, the PR may be closed without review. Please ensure all checks pass. If you are a new contributor, the workflows will need to be manually approved before they run. --> ## Brief summary <!-- Please provide a brief summary of what your PR attempts to achieve. --> Allow users to sort narrators by name and book count. ## Which issue is fixed? <!-- Which issue number does this PR fix? Ex: "Fixes #1234" --> Fixes https://github.com/advplyr/audiobookshelf/issues/4584 ## In-Depth Description <!-- Describe your solution in more depth. How does it work? Why is this the best solution? Does it solve a problem that affects multiple users or is this an edge case for your setup? --> **How the narrator sorting works:** Users can sort narrators by clicking on the corresponding table header cells. When hovering over these cells, the cursor changes to a pointer. Because there are no lines separating the tabel cells, the text in the corresponding cell is underlined. Clicking the same header again toggles the sorting direction (ascending/descending). An arrow icon visually indicates the current sorting direction and only appears in the active column to show which column is being sorted. To ensure the visual indicators and sorting logic remain in sync, both are driven by shared state properties like the currently selected attribute and sort order. Those parameters are used as query params when fetching the narrators. On the server side the query params from the request are replaced with known strings to ensure working default and fallback sorting options, before sorting the list of narrators using naturalSort(). **Why this solution is effective:** It follows the design principle of *external consistency*—the behavior and appearance mimic commonly used sortable tables, making the feature intuitive and familiar for users. Server side sorting will work in the future even when paging is added. **Areas for Improvement:** The current implementation uses a Unicode arrow character returned from a function. This wasn't my first choice; I would have preferred using an icon to support `aria-labels`. However, I was unable to insert a standalone icon without also introducing a button. If icon-based implementation is preferred, I would appreciate guidance on the icon library and documentation used in this project, along with relevant code examples. Fetching a new list of narrators every time the order changes is a bit slow and creates unnecessary traffic, this could be improved by caching. **Who is affected:** While the change is small, it affects many users because it adds function to the web client. ## How Have You Tested This? I ran the project inside a dev container. Then I added sample audiobooks as test data and navigated to the narrator page in a web browser. I verified the behavior when hovering over, clicking, and repeatedly interacting with the header cells of sortable columns. Additionally, I confirmed that the edit and delete buttons next to each narrator still function as expected. ## Screenshots <!-- If your PR includes any changes to the web client, please include screenshots or a short video from before and after your changes. --> Before: <img width="1918" height="939" alt="image" src="https://github.com/user-attachments/assets/67e940a7-abcc-429c-9e1b-34aeebf44f86" /> After: <img width="1919" height="939" alt="image" src="https://github.com/user-attachments/assets/b58fdb18-5dc3-4aae-a90c-83d3c5e64446" /> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2026-04-25 00:19:24 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#4355