🐛 Fix page size dropdown on review page #79
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/issue-78-page-size-dropdown"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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 <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 #78WuMing
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.
line 0
✅ Added tests for handle_set_page_size() in commit
02ea11e: valid size change resets page and reloads, invalid sizes are rejected.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.
packages/fenliu/tests/test_liveviews.pyline 0✅ Added assertion in commit
46cea58: post IDs are captured before the call and verified unchanged after.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.