Skip to content

manage_tables.js: delete action should backfill removed rows instead of refreshing the whole table #4724

Open

Description

@objecttothis

Background

While implementing live row updates for the Jobs Manage grid (#3833 — Plugin Queue Management: Pause, Resume, and Uninstall), the play/pause row actions were changed to fade out a processed/paused row, remove it from the table client-side, and fetch exactly one replacement row from what would have been the next page — no full table reload, no page jump, no loss of scroll position.

The shared do_action() helper in public/js/manage_tables.js (used by the Delete button on every Manage grid in the app) does the fade-out animation correctly, but afterward unconditionally calls refresh(), which re-queries the server and re-renders the entire table:

// public/js/manage_tables.js, do_action()
$(this).find("td").animate({backgroundColor: "green"}, 1200, "linear")
    .end().animate({opacity: 0}, 1200, "linear", function () {
    table().remove({
        field: options.uniqueId,
        values: selected_ids()
    });
    if (index == $(selector).length - 1) {
        refresh();          // <-- full reload instead of backfilling just the removed rows
        enable_actions();
    }
});

Jobs' Manage grid now has its own local removeRowsAndBackfill() (in app/Views/jobs/manage_grid.php) that does this correctly for its own actions, but Delete on that same grid still goes through the shared do_action() path and therefore still does a full-table refresh — inconsistent with Play/Pause on the same page.

What needs to change

In public/js/manage_tables.js, do_action()'s delete success handler should, after the fade/remove animation completes, fetch only as many replacement rows as were removed (using the same offset/limit/sort/order the table last queried with) and table().append() just those rows — instead of calling refresh().

Suggested reusable design

Generalize the pattern already proven in app/Views/jobs/manage_grid.php:

  1. Track the table's last-sent query params (the exact object passed to the queryParams hook) in a module-level variable inside the table_support IIFE, so any caller can replay the same search/sort/order/limit/offset/custom filters without having to re-derive them from bsTable.options (which proved unreliable — reading those fields directly during polling produced intermittent unbounded/missing limit params and full-table-sized responses).
  2. Add a table_support method, e.g. removeRowsAndBackfill(ids):
    • Snapshot currently-visible unique IDs (table().getData({useCurrentPage: true})).
    • Remove the given ids via table().remove({field: options.uniqueId, values: ids}).
    • Issue one $.get(options.resource + '/search', {...lastQueryParams, offset: lastOffset + lastLimit - ids.length, limit: ids.length}) to fetch replacement rows.
    • Filter out any returned rows already visible (avoids duplicates if a backfill candidate was already on-page from a concurrent change) and table().append() the rest.
    • Fall back to refresh() if there's no table instance or no captured query params yet (first load, or a resource whose search endpoint doesn't support this).
  3. Update do_action()'s delete handler to call table_support.removeRowsAndBackfill(selected_ids()) instead of table().remove(...) + refresh().
  4. Keep refresh() as the fallback for any action whose result can't be expressed as "these rows are gone, backfill N more" (e.g. restore, bulk edits that change sort order).

This would let every Manage grid in the app (not just Jobs) get the same "fade out, shift up" delete behavior for free, and gives other features (like Jobs' own poll-driven row removal) a shared, tested implementation to call into instead of re-implementing it per view.

Files likely involved

  • public/js/manage_tables.js (do_action(), table_support IIFE)
  • app/Views/jobs/manage_grid.php (can switch its local removeRowsAndBackfill/removeRowAndBackfill over to the shared implementation once it exists, removing the duplication)

Activity

  1. objecttothis commented on Oct 23, 2026

    @objecttothis
    MemberAuthor

    Claude Issue Checker Agent (cc @objecttothis)

    Investigated against current master.

    Status: Still present (refactor not done).

    In public/js/manage_tables.js, do_action()'s success handler still does:

    table().remove({ field: options.uniqueId, values: selected_ids() });
    if (index == $(selector).length - 1) {
        refresh();          // full reload
        enable_actions();
    }

    — there is no removeRowsAndBackfill()-style method, no tracked "last query params" module-level variable, and no table().append() backfill call anywhere in this file. A search for removeRowsAndBackfill across the repo only matches app/Views/jobs/manage_grid.php's local implementation, confirming it hasn't been generalized into the shared table_support IIFE yet, and do_action()'s delete handler still calls the shared refresh() (full table reload) exactly as described in the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions