PostStream requests the next page too late, so arriving posts shove the footer off screen (CLS ~0.9 on mobile)
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 78/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- javascript
- Lĩnh vực
- frontend, performance
Hướng nghiên cứu
Bắt đầu tại framework/core/js/src/forum/components/PostStream.js, ở các dòng 227-241, và kiểm tra PostStream#loadPostsIfNeeded(). Tái hiện kịch bản mobile ở 412x823 trên kết nối bị giới hạn, sau đó xác minh rằng trang tiếp theo được yêu cầu sớm hơn và các bài viết xuất hiện mà không đẩy footer vào vùng hiển thị; issue cũng yêu cầu một regression test.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Current Behavior
PostStream#loadPostsIfNeeded() only requests the next page of posts once the end of the loaded stream comes within a fixed 300 px of the viewport bottom:
const loadAheadDistance = 300;
...
if ($item.length && $item.offset().top + $item.outerHeight(true) < viewportTop + viewportHeight + loadAheadDistance) {
this.stream.loadNext();
}
On a phone, on a real connection, that request is still in flight when the page footer scrolls into view. The posts then arrive and shove the footer out of the viewport — one layout shift of ~0.9, which on its own rates the whole page view "poor" for CLS.
It reproduces for guests and members alike, on every discussion with more than one page of posts, so it affects a large share of mobile discussion views on any forum.
Captured from the shift entry (mobile viewport 412x823):
v=0.8967 DIV.custom-footer prev y=743 h=79 -> cur y=0 h=0
PostStream items 20 -> 40, stream height 11366 -> 18937
Desktop is essentially unaffected (measured 0.003 on the same thread) because the same footer movement is a much smaller fraction of a large viewport — which is why this tends to show up only in the mobile half of Search Console's Core Web Vitals report.
Steps to Reproduce
- Open a discussion with more than 20 posts on a phone-sized viewport (412x823), on a throttled connection (~1.6 Mbps, 150 ms latency).
- Scroll to the bottom of the first page of posts so the footer comes into view.
- Watch the footer as the next page arrives — it is pushed off screen.
Measured with a buffered PerformanceObserver on layout-shift (hadRecentInput entries excluded), scrolling with real wheel input via CDP Input.dispatchMouseEvent, headless Chrome 140, 4x CPU throttle.
Expected Behavior
The next page should be requested early enough that it arrives while the end of the stream is still below the fold, so the growth happens off screen and costs no layout shift. The same pages are fetched either way — only the timing changes.
Scaling the look-ahead with the viewport instead of using a fixed 300 px is enough:
const loadAheadDistance = Math.max(300, $(window).height() * 1.5);
Measured on an 85-post discussion read to the bottom: CLS 0.897 -> 0.018.
I have this running in production as an extension override and am happy to open a PR with a regression test if the approach looks right.
Environment
- Flarum version: 2.0.0-rc.8
- Website URL: https://pianoclack.com
- Webserver: nginx
- Hosting environment: VPS
- PHP version: 8.4.24
- Browser: Chrome 140 (mobile emulation, and reproduced on real Android Chrome field data)
- Ngôn ngữ chính
- PHP
- Star
- 6.8k
- Fork
- 891
- Merge trung bình
- 1 ngày 10 giờ
- Pull request đã merge (30 ngày)
- 209
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của flarum/framework
-
type/accessibility type/bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Default language is ignored for anyone who chose a language, when the language selector is hiddenCó thể đã có người làm @1AbdullahButt đã nhận 15 ngày trước. Đang mởtype/bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[2.x] False CLI/Web PHP mismatch when /usr/bin/php differs from the site's FPMCó thể đã có người làm @lazerg đã nhận 15 ngày trước. Đang mởtype/bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[2.x] A filter on a resource without a searcher returns a 500Có thể đã có người làm @imorland đã nhận hôm nay. Đang mởtype/bug
flarum/framework#5578 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[2.x] Audit's discussion and user filters fail on PostgreSQLCó thể đã có người làm @imorland đã nhận hôm nay. Đang mởtype/bug
flarum/framework#5577 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của flarum/framework
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 87/100
Sylius/Sylius#19359 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Add php 8.6Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 66/100
mailersend/mailersend-php#199 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Tool: somcp_delete_currencyĐang mởConfiguration new tool
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
novalo-dev/Prestashop-MCP-Server#366 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Maintainer thường phản hồi trong vòng 10 ngày