[openstreetmap/openstreetmap-website] Fix element pagination width calculation (PR #5211)
mmd
notifications at github.com
Sat Sep 14 07:11:58 UTC 2024
@mmd-osm commented on this pull request.
> @@ -86,7 +86,7 @@ def sidebar_classic_pagination(pages, page_param)
max_width_for_default_padding = 35
width = 0
- pagination_items(pages, {}).each do |body|
+ pagination_items(pages, {}).each do |(body)|
Body is an array, like `["3", "active"]`, so applying `each_key` here might be a bit confusing (why is the first array element a key?). On the other hand, I'm not clear how `(body)` works.
In my proposal I left this part as is, and opted to access the array by element index instead:
`width += body.first.length` or `width += body[0].length`
By the way, I was wondering a bit why pagination_items returns an array of arrays, instead an array of hashes, where the purpose of each attribute would be a bit clearer. That's maybe something for another issue.
--
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/5211#discussion_r1759685356
You are receiving this because you are subscribed to this thread.
Message ID: <openstreetmap/openstreetmap-website/pull/5211/review/2304396674 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20240914/54ee4430/attachment.htm>
More information about the rails-dev
mailing list