wars2k / booktracker

Selfhosted app for organizing your library and tracking your reading habits.
MIT License
45 stars 1 forks source link

set rating from my books table does not work #35

Open wolflu05 opened 10 months ago

wolflu05 commented 10 months ago

Setting the rating from the table view does not work and results in undefined. https://github.com/wars2k/booktracker/assets/76838159/e56615a6-62f0-4bbf-b68c-260c8c7644ab

wars2k commented 10 months ago

I'm struggling to reproduce this issue. Is this a book that you imported from goodreads? Is it happening on every book? Also, what version are you using?

wolflu05 commented 10 months ago

Sorry that I forgot to provide the version information. I installed it using the docker image (wars2k/booktracker@sha256:201b1f4c7d139418a48b8fe472f466eefd1c229014f1efb37b71384cd34876a1 (current latest)). This happens with all books no matter if they are imported using the book search or the manual entry. (Haven't tested with Goodreads imports because I have not used Goodreads).

I now tried to investigate the issue a bit more and it seems like that it's because safari adds <br> to the innerHTML of the select elements and that adds a length of 4 to the stars string so setting 4 stars actually sends 8 which results in undefined. Determine the select option based in the innerHTML length is not a good idea, however I'm wondering why you don't just use a html select element that has options already built-in, but the easiest fix maybe would be to use the .innerText and then trim any whitespace around it. image