🐛 Fix page size dropdown on review page #79

Manually merged
marvin8 merged 5 commits from fix/issue-78-page-size-dropdown into main 2026-08-04 06:22:20 +00:00
Collaborator

The per-page dropdown at the bottom of the /review LiveView page had no effect because the element lacked a name attribute. Without name="value", the browser did not include the selected value in the phx-change event payload, so the handler always fell back to the default of 20.

Fix: Add name="value" to the

element in _render_table_footer().

Closes #78

The per-page dropdown at the bottom of the /review LiveView page had no effect because the <select> element lacked a name attribute. Without name="value", the browser did not include the selected value in the phx-change event payload, so the handler always fell back to the default of 20. Fix: Add name="value" to the <select> element in _render_table_footer(). Closes #78
🐛 Add missing name attribute to page size select
All checks were successful
/ gitleaks (pull_request) Successful in 17s
/ pr-review (pull_request) Successful in 31s
/ checks (pull_request) Successful in 4m54s
/ publish (pull_request) Has been skipped
/ publish-container (pull_request) Has been skipped
/ deploy-docs (pull_request) Has been skipped
c903545629
The <select> element in _render_table_footer() lacked a name attribute,
so the browser never included the selected value in the phx-change
event payload. handle_set_page_size always received payload.get("value", 20)
which fell back to the default of 20, making the dropdown appear to do nothing.

Closes #78
forgejo-actions left a comment

WuMing

Found 1 issue(s). See inline comments below.

## WuMing Found **1** issue(s). See inline comments below.
@ -1398,3 +1398,3 @@
page_size_select = (
f'<label class="flex items-center gap-1 text-sm text-gray-500">'
f'Per page: <select phx-change="set_page_size" class="{select_cls}">{size_options}</select>'
f'Per page: <select name="value" phx-change="set_page_size" class="{select_cls}">{size_options}</select>'

tests [LOW]

Source file modified with a behavior-affecting change: adding name="value" to the select changes the parameter sent in the set_page_size LiveView event. No test file appears in this diff, so add or update tests covering the page-size selection event payload to verify this behavior.

**tests** [LOW] Source file modified with a behavior-affecting change: adding name="value" to the select changes the parameter sent in the set_page_size LiveView event. No test file appears in this diff, so add or update tests covering the page-size selection event payload to verify this behavior. <!-- wuming:sha256:7071166e1296c96bfc74b374b9795ee7b1b1871d6c17843bc6155d0294b11abf -->
marvin8 marked this conversation as resolved
Author
Collaborator

line 0

Source file modified with a behavior-affecting change

Added tests for handle_set_page_size() in commit 02ea11e: valid size change resets page and reloads, invalid sizes are rejected.

[ line 0](https://forge.marvin8.zone/marvin8/dujiangyan/pulls/79#issuecomment-336) > Source file modified with a behavior-affecting change ✅ Added tests for handle_set_page_size() in commit 02ea11e: valid size change resets page and reloads, invalid sizes are rejected.
Add tests for handle_set_page_size
All checks were successful
/ gitleaks (pull_request) Successful in 17s
/ pr-review (pull_request) Successful in 36s
/ checks (pull_request) Successful in 4m50s
/ publish (pull_request) Has been skipped
/ publish-container (pull_request) Has been skipped
/ deploy-docs (pull_request) Has been skipped
02ea11ea53
forgejo-actions left a comment

WuMing

Found 1 issue(s). See inline comments below.

## WuMing Found **1** issue(s). See inline comments below.
@ -950,0 +985,4 @@
await view.handle_set_page_size({"value": "99"})
expect(view.page_size, "page_size").to_equal(original_size)
expect(view.page, "page").to_equal(original_page)

code [MEDIUM]

The invalid‑size test only verifies page_size and page are unchanged. It should also assert that posts were not reloaded (e.g., same list identity or unchanged content). Otherwise a handler that reloads with the original parameters could pass undetected.

**code** [MEDIUM] The invalid‑size test only verifies page_size and page are unchanged. It should also assert that posts were not reloaded (e.g., same list identity or unchanged content). Otherwise a handler that reloads with the original parameters could pass undetected. <!-- wuming:sha256:b2f9d917d05b787fbcf8858e876fca6dc0b37d03be9411b08e0725af492d3250 -->
marvin8 marked this conversation as resolved
Author
Collaborator

packages/fenliu/tests/test_liveviews.py line 0

It should also assert that posts were not reloaded

Added assertion in commit 46cea58: post IDs are captured before the call and verified unchanged after.

[`packages/fenliu/tests/test_liveviews.py` line 0](https://forge.marvin8.zone/marvin8/dujiangyan/pulls/79#issuecomment-340) > It should also assert that posts were not reloaded ✅ Added assertion in commit 46cea58: post IDs are captured before the call and verified unchanged after.
Also assert posts unchanged on invalid page size
All checks were successful
/ gitleaks (pull_request) Successful in 16s
/ pr-review (pull_request) Successful in 34s
/ checks (pull_request) Successful in 4m54s
/ publish (pull_request) Has been skipped
/ publish-container (pull_request) Has been skipped
/ deploy-docs (pull_request) Has been skipped
46cea58d1b
🐛 Handle parse_qs list values in handle_set_page_size
All checks were successful
/ gitleaks (pull_request) Successful in 18s
/ pr-review (pull_request) Successful in 40s
/ checks (pull_request) Successful in 5m7s
/ publish (pull_request) Has been skipped
/ publish-container (pull_request) Has been skipped
/ deploy-docs (pull_request) Has been skipped
3ab7ac596a
The phx-change event goes through parse_qs in ws_handler, which
converts URL-encoded form data into dict-of-lists. payload.get("value")
returned ["50"] (a list), and int(["50"]) raised TypeError, silently
returning without changing page_size. Now normalise list values by
extracting the first element, matching _normalize_filter_value pattern.
🐛 Wrap page size select in form so change event reaches server
All checks were successful
/ gitleaks (pull_request) Successful in 17s
/ pr-review (pull_request) Successful in 43s
/ checks (pull_request) Successful in 5m11s
/ publish (pull_request) Has been skipped
/ publish-container (pull_request) Has been skipped
/ deploy-docs (pull_request) Has been skipped
34c96192d7
The select had phx-change but no ancestor <form>, so inputEl.form was
null and new FormData(null) threw in the browser before any websocket
frame was sent. handle_set_page_size was never invoked: no re-render
and page_size never updated for subsequent page navigation. Wrap the
select in <form phx-change="set_page_size"> so the event pushes as a
form change, which the handler already supports.
marvin8 approved these changes 2026-08-04 06:21:30 +00:00
marvin8 manually merged commit c3cffbde09 into main 2026-08-04 06:22:20 +00:00
marvin8 deleted branch fix/issue-78-page-size-dropdown 2026-08-04 06:22:50 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
marvin8/dujiangyan!79
No description provided.