fix(ajax): show the reference skeleton on every load-more surface

Clicking 加载更多 in the 多栏目文章 widget showed no skeleton at all — the
list simply stayed still until the response arrived, then the new cards
appeared. The homepage stream, archives and comments already had a working
skeleton; the widget's AJAX load goes through a different client and never
found its loader.

Root cause was DOM placement, not visibility: ContentRenderer emitted
.post_ajax_loader as a *sibling* of .widget-ajaxpager, while the widget REST
client resolves it with container.querySelector('.post_ajax_loader'). The
node existed but could never match, so .is-loading was never added and the
skeleton stayed display:none. Inactive tab panes had the same shape, and the
direct-load branch of ajaxpager() emitted no loader at all.

Changes, all following the reference theme's post_ajax() contract in
zibll/js/main.js (beforeSend anchors the loader to the end of the list;
success only hides it, never removes it):

- ContentRenderer: nest the loader inside .widget-ajaxpager for both the
  direct-load and inactive-tab branches, and drop the sibling append.
- widgets/frontend.js: anchorLoader() moves the loader to the end of the
  list before .ajax-pag on every request; appended cards are inserted before
  it; a replace preserves the node instead of wiping it with innerHTML; a
  fallback loader is created when the DOM has none; loadItems() now returns
  its promise; drop the unreachable is-loading auto-load branch.
- Message centre, user-home panels and the search page switch from spinner /
  opacity feedback to the same .posts-item-shaped skeleton, so all AJAX
  surfaces share one loading contract.
- Remove the second, never-wired skeleton system (.aksrt-skeleton-* in
  core-ui.css) and the dead spinner stylesheets/rules (skeleton.css,
  ajax-spinner.css, .load-more__*, --skeleton-base/--skeleton-shine) plus the
  unregistered assets/js/waterfall.js.
- Extend the widget, message-centre, user-home and asset-ledger contract
  tests to pin the loader inside the container, the class-only visibility
  switch, and the absence of the deleted dead code.

Verified: 470 node tests, 136 PHP widget assertions, admin-contract and
widget-system audits all green; rebuilt public assets after the CSS/JS
removals.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-10-03 22:22:15 +08:00
co-authored by Claude Fable 5
parent 271e7f0518
commit cf4554e7c8
25 changed files with 330 additions and 981 deletions
+1
View File
@@ -55,6 +55,7 @@ require_once AKSRT_DIR . '/inc/helpers/aksrt-null.php';
require_once AKSRT_DIR . '/inc/helpers/user-ban.php';
require_once AKSRT_DIR . '/inc/helpers/aksrt-ajax-list.php';
require_once AKSRT_DIR . '/inc/helpers/aksrt-links.php';
require_once AKSRT_DIR . '/inc/helpers/message-placeholder.php';
require_once AKSRT_DIR . '/inc/helpers/search/aksrt-search-posts.php';
require_once AKSRT_DIR . '/inc/helpers/search/aksrt-search-box.php';
require_once AKSRT_DIR . '/inc/helpers/aksrt-header-userbox.php';
+37
View File
@@ -0,0 +1,37 @@
<?php
/**
* Message centre skeleton placeholder.
*
* The message list is not an article stream, so it reuses the shared
* `.placeholder` block contract (`inc/helpers/posts-renderer/markup.php`)
* while mirroring the real `.message-item` geometry — circular icon dot,
* title bar, description bar and a time bar. Rendered inside the standard
* `.post_ajax_loader` shell so `messages.js` can toggle `.is-loading` the
* same way `pagination.js` does for post lists.
*
* @package AKSRT
*/
defined('ABSPATH') || exit;
if (!function_exists('aksrt_get_message_placeholder')) {
/**
* Build the message-centre skeleton for the AJAX load-more cycle.
*
* @param int $count Repeated message rows, 1–12.
* @return string
*/
function aksrt_get_message_placeholder(int $count = 4): string {
$count = max(1, min(12, $count));
$item = '<article class="message-item message-item--placeholder" aria-hidden="true">'
. '<span class="message-item__icon placeholder"></span>'
. '<div class="message-item__body">'
. '<div class="placeholder t1" style="width: 62%;"></div>'
. '<div class="placeholder k2 mt6" style="width: 88%;"></div>'
. '<div class="placeholder s1 mt10"></div>'
. '</div>'
. '<div class="message-item__actions"><span class="placeholder s1" style="width: 46px;"></span></div>'
. '</article>';
return '<div class="post_ajax_loader">' . str_repeat($item, $count) . '</div>';
}
}
+5
View File
@@ -226,6 +226,11 @@ function aksrt_render_message_center_list(int $user_id, string $view, int $page
?>
<div class="messages-list">
<?php foreach ($items as $item) { aksrt_render_message_item($item, $view); } ?>
<?php
if (function_exists('aksrt_get_message_placeholder')) {
echo aksrt_get_message_placeholder(4); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- 固定骨架结构。
}
?>
</div>
<?php if ($total_pages > 1) : ?>
<?php if ($paginate_type === 'ajax_lists' && $page < $total_pages) : ?>