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:
@@ -69,6 +69,36 @@ test('message pagination setting switches between cumulative loading and numeric
|
||||
assert.match(styles, /\.messages-pagination__button\.is-current/);
|
||||
});
|
||||
|
||||
test('message centre shows a skeleton during the AJAX load-more cycle', () => {
|
||||
const list = read('inc/modules/message-center.php');
|
||||
const placeholder = read('inc/helpers/message-placeholder.php');
|
||||
const script = read('assets/js/messages.js');
|
||||
const styles = read('assets/css/frontend/messages.css');
|
||||
|
||||
// The skeleton ships inside .messages-list so the loader is anchored to the
|
||||
// end of the list, mirroring the reference post_ajax beforeSend hook.
|
||||
assert.match(list, /aksrt_get_message_placeholder\(4\)/);
|
||||
assert.match(placeholder, /message-item--placeholder/);
|
||||
assert.match(placeholder, /class="post_ajax_loader"/);
|
||||
// The message skeleton reuses the shared .placeholder shimmer contract.
|
||||
assert.match(placeholder, /placeholder t1/);
|
||||
assert.match(placeholder, /placeholder k2/);
|
||||
assert.match(placeholder, /placeholder s1/);
|
||||
|
||||
// Load cycle: show on start, hide on finish, and never remove the node.
|
||||
assert.match(script, /content\.querySelector\('\.messages-list > \.post_ajax_loader'\)/);
|
||||
assert.match(script, /skeleton\.classList\.add\('is-loading'\)/);
|
||||
assert.match(script, /loader\.classList\.remove\('is-loading'\)/);
|
||||
// Appended rows land before the skeleton so it stays flush under the list.
|
||||
assert.match(script, /currentList\.insertBefore\(item, skeleton\)/);
|
||||
|
||||
// Visibility is class-driven; the old button spinner / opacity dim are gone.
|
||||
assert.match(styles, /\.messages-list > \.post_ajax_loader \{/);
|
||||
assert.match(styles, /\.messages-list > \.post_ajax_loader\.is-loading \{/);
|
||||
assert.doesNotMatch(styles, /messages-pagination-spin/);
|
||||
assert.doesNotMatch(styles, /opacity: 0\.55/);
|
||||
});
|
||||
|
||||
test('tabs, pagination, actions, and detail all replace DOM fragments', () => {
|
||||
const center = read('inc/modules/message-center.php');
|
||||
const script = read('assets/js/messages.js');
|
||||
|
||||
Reference in New Issue
Block a user