[Bug]: White space cleanup when editing book in both regular and bulk edit #2553

Closed
opened 2026-04-25 00:08:19 +02:00 by adam · 5 comments
Owner

Originally created by @ZLoth on GitHub (Feb 6, 2025).

What happened?

There is no white space cleanup when editing the book information. . If there is whitespace at the beginning of a book title, then the sort order is messed up as the white space at the beginning of a book title means that it is ranked higher than numbers and letters.

What did you expect to happen?

White space should be stripped of all test-field boxes. It should emulate what is currently being done with the Chapter Editor.

Recording of chapter editor:

https://github.com/user-attachments/assets/aa026129-582b-4978-b486-f5143c3fe3e5

Steps to reproduce the issue

For both recreations, make sure that you are in library view, and sorting is set to "All" and "Title Ascending".

Regular book editing:

  1. Edit a book at the end of the list (e.g. You Are Here)
  2. Put a blank space at the beginning of the title.
  3. Save and Close the book.
  4. Refresh the Library.

WHAT SHOULD HAPPEN: The whitespace is removed at both the beginning and end of the title, and the book retains it's position in the library.
WHAT REALLY HAPPENS: The book title is moved to the top of the list as the title now has a space at the beginning.

Issue also occurs in bulk edit.

Recording of the issue.
https://github.com/user-attachments/assets/b5befbcf-2f32-4eca-80a5-9ff9ffb6066c

Audiobookshelf version

2.19.0

How are you running audiobookshelf?

Docker

What OS is your Audiobookshelf server hosted from?

Linux

If the issue is being seen in the UI, what browsers are you seeing the problem on?

Chrome

Logs

2025-02-06 07:46:10.847

DEBUG

[Book] " You Are Here" changed keys: [ 'title', 'titleIgnorePrefix' ]

2025-02-06 07:46:10.932

DEBUG

[LibraryItem] Saved metadata for " You Are Here" file to "/audiobooks/Audiobooks/Soundscapes/You Are Here/metadata.json"

2025-02-06 07:46:10.932

DEBUG

[LibraryItemController] Updated library item media " You Are Here"

2025-02-06 07:46:52.037

DEBUG

[Book] "You Are Here" changed keys: [ 'title', 'titleIgnorePrefix' ]

2025-02-06 07:46:52.147

DEBUG

[LibraryItem] Saved metadata for "You Are Here" file to "/audiobooks/Audiobooks/Soundscapes/You Are Here/metadata.json"

2025-02-06 07:46:52.147

DEBUG

[LibraryItemController] Updated library item media You Are Here

2025-02-06 07:56:01.417

DEBUG

[Book] " You Are Here" changed keys: [ 'title', 'titleIgnorePrefix' ]

2025-02-06 07:56:01.540

DEBUG

[LibraryItem] Saved metadata for " You Are Here" file to "/audiobooks/Audiobooks/Soundscapes/You Are Here/metadata.json"

2025-02-06 07:56:01.540

DEBUG

[LibraryItemController] Updated library item media You Are Here

2025-02-06 07:56:31.801

DEBUG

[Book] " You Are Here" changed keys: [ 'title', 'titleIgnorePrefix' ]

2025-02-06 07:56:31.934

DEBUG

[LibraryItem] Saved metadata for " You Are Here" file to "/audiobooks/Audiobooks/Soundscapes/You Are Here/metadata.json"

2025-02-06 07:56:31.934

DEBUG

[LibraryItemController] Updated library item media You Are Here

2025-02-06 07:56:49.731

DEBUG

[Book] "You Are Here" changed keys: [ 'title', 'titleIgnorePrefix' ]

2025-02-06 07:56:49.880

DEBUG

[LibraryItem] Saved metadata for "You Are Here" file to "/audiobooks/Audiobooks/Soundscapes/You Are Here/metadata.json"

2025-02-06 07:56:49.880

DEBUG

[LibraryItemController] Updated library item media You Are Here

Additional Notes

No response

Originally created by @ZLoth on GitHub (Feb 6, 2025). ### What happened? There is no white space cleanup when editing the book information. . If there is whitespace at the beginning of a book title, then the sort order is messed up as the white space at the beginning of a book title means that it is ranked higher than numbers and letters. ### What did you expect to happen? White space should be stripped of all test-field boxes. It should emulate what is currently being done with the Chapter Editor. Recording of chapter editor: https://github.com/user-attachments/assets/aa026129-582b-4978-b486-f5143c3fe3e5 ### Steps to reproduce the issue For both recreations, make sure that you are in library view, and sorting is set to "All" and "Title Ascending". Regular book editing: 1. Edit a book at the end of the list (e.g. You Are Here) 2. Put a blank space at the beginning of the title. 3. Save and Close the book. 4. Refresh the Library. WHAT SHOULD HAPPEN: The whitespace is removed at both the beginning and end of the title, and the book retains it's position in the library. WHAT REALLY HAPPENS: The book title is moved to the top of the list as the title now has a space at the beginning. Issue also occurs in bulk edit. Recording of the issue. https://github.com/user-attachments/assets/b5befbcf-2f32-4eca-80a5-9ff9ffb6066c ### Audiobookshelf version 2.19.0 ### How are you running audiobookshelf? Docker ### What OS is your Audiobookshelf server hosted from? Linux ### If the issue is being seen in the UI, what browsers are you seeing the problem on? Chrome ### Logs ```shell 2025-02-06 07:46:10.847 DEBUG [Book] " You Are Here" changed keys: [ 'title', 'titleIgnorePrefix' ] 2025-02-06 07:46:10.932 DEBUG [LibraryItem] Saved metadata for " You Are Here" file to "/audiobooks/Audiobooks/Soundscapes/You Are Here/metadata.json" 2025-02-06 07:46:10.932 DEBUG [LibraryItemController] Updated library item media " You Are Here" 2025-02-06 07:46:52.037 DEBUG [Book] "You Are Here" changed keys: [ 'title', 'titleIgnorePrefix' ] 2025-02-06 07:46:52.147 DEBUG [LibraryItem] Saved metadata for "You Are Here" file to "/audiobooks/Audiobooks/Soundscapes/You Are Here/metadata.json" 2025-02-06 07:46:52.147 DEBUG [LibraryItemController] Updated library item media You Are Here 2025-02-06 07:56:01.417 DEBUG [Book] " You Are Here" changed keys: [ 'title', 'titleIgnorePrefix' ] 2025-02-06 07:56:01.540 DEBUG [LibraryItem] Saved metadata for " You Are Here" file to "/audiobooks/Audiobooks/Soundscapes/You Are Here/metadata.json" 2025-02-06 07:56:01.540 DEBUG [LibraryItemController] Updated library item media You Are Here 2025-02-06 07:56:31.801 DEBUG [Book] " You Are Here" changed keys: [ 'title', 'titleIgnorePrefix' ] 2025-02-06 07:56:31.934 DEBUG [LibraryItem] Saved metadata for " You Are Here" file to "/audiobooks/Audiobooks/Soundscapes/You Are Here/metadata.json" 2025-02-06 07:56:31.934 DEBUG [LibraryItemController] Updated library item media You Are Here 2025-02-06 07:56:49.731 DEBUG [Book] "You Are Here" changed keys: [ 'title', 'titleIgnorePrefix' ] 2025-02-06 07:56:49.880 DEBUG [LibraryItem] Saved metadata for "You Are Here" file to "/audiobooks/Audiobooks/Soundscapes/You Are Here/metadata.json" 2025-02-06 07:56:49.880 DEBUG [LibraryItemController] Updated library item media You Are Here ``` ### Additional Notes _No response_
adam added the bug label 2026-04-25 00:08:19 +02:00
adam closed this issue 2026-04-25 00:08:19 +02:00
Author
Owner

@nichwall commented on GitHub (Feb 6, 2025):

I agree we should probably trim the white space from titles.

On a related note, we probably need to make a list of exactly what fields should trim whitespace and what should not. There was a feature request recently to prevent white space trimming in the chapter editor. https://github.com/advplyr/audiobookshelf/issues/3722

@nichwall commented on GitHub (Feb 6, 2025): I agree we should probably trim the white space from titles. On a related note, we probably need to make a list of exactly what fields should trim whitespace and what should not. There was a feature request recently to *prevent* white space trimming in the chapter editor. https://github.com/advplyr/audiobookshelf/issues/3722
Author
Owner

@ZLoth commented on GitHub (Feb 6, 2025):

It would be easier to identify which fields should not be whitespaced than which fields should be whitespaced.

@ZLoth commented on GitHub (Feb 6, 2025): It would be easier to identify which fields should _not_ be whitespaced than which fields should be whitespaced.
Author
Owner

@advplyr commented on GitHub (Feb 7, 2025):

I added the trim to every text input. I'm not a fan of #3722 but maybe someone will have a better reason to preserve whitespace on other inputs we'll see

@advplyr commented on GitHub (Feb 7, 2025): I added the trim to every text input. I'm not a fan of #3722 but maybe someone will have a better reason to preserve whitespace on other inputs we'll see
Author
Owner

@ZLoth commented on GitHub (Feb 7, 2025):

I added the trim to every text input.

As always, thank you, and looking forward to the release.

I'm not a fan of #3722 but maybe someone will have a better reason to preserve whitespace on other inputs we'll see

I do see the roots of where this idea originated and had previously suggested https://github.com/advplyr/audiobookshelf/issues/3421 as well. The root of both ideas is the same: There are books with multiple "sections" and there should be a way to highlight those sections. The other person wanted to indent the chapters, I wanted to be able to bold/italicize/underline the sections.

@ZLoth commented on GitHub (Feb 7, 2025): > I added the trim to every text input. As always, thank you, and looking forward to the release. > I'm not a fan of [#3722](https://github.com/advplyr/audiobookshelf/issues/3722) but maybe someone will have a better reason to preserve whitespace on other inputs we'll see I do see the roots of where this idea originated and had previously suggested https://github.com/advplyr/audiobookshelf/issues/3421 as well. The root of both ideas is the same: There are books with multiple "sections" and there should be a way to highlight those sections. The other person wanted to indent the chapters, I wanted to be able to bold/italicize/underline the sections.
Author
Owner

@github-actions[bot] commented on GitHub (Feb 12, 2025):

Fixed in v2.19.1.

@github-actions[bot] commented on GitHub (Feb 12, 2025): Fixed in [v2.19.1](https://github.com/advplyr/audiobookshelf/releases/tag/v2.19.1).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#2553