fix(admin): correct HTMX event name for team list refresh#2705
fix(admin): correct HTMX event name for team list refresh#2705crivetimihai merged 1 commit intoIBM:mainfrom
Conversation
| @@ -4597,7 +4597,7 @@ async def admin_update_team( | |||
| </div> | |||
| """ | |||
| response = HTMLResponse(content=success_html) | |||
| response.headers["HX-Trigger"] = orjson.dumps({"adminTeamAction": {"closeTeamEditModal": True, "refreshTeamsList": True, "delayMs": 1500}}).decode() | |||
| response.headers["HX-Trigger"] = orjson.dumps({"adminTeamAction": {"closeTeamEditModal": True, "refreshUnifiedTeamsList": True, "delayMs": 1500}}).decode() | |||
There was a problem hiding this comment.
I think this event name is used on this chunk of the admin.js file:
if (detail.refreshTeamsList) {
const teamsList = safeGetElement("teams-list");
if (teamsList && window.htmx) {
window.htmx.trigger(teamsList, "load");
}
}refreshUnifiedTeamsList is used on the segment below:
if (detail.refreshUnifiedTeamsList && window.htmx) {
const unifiedList = document.getElementById("unified-teams-list");
if (unifiedList) {
// Preserve current pagination/filter state on refresh
const params = new URLSearchParams();
params.set("page", "1"); // Reset to first page on action
if (typeof getTeamsPerPage === "function") {
params.set("per_page", getTeamsPerPage().toString());
}
// Preserve search query from input field
const searchInput = document.getElementById("team-search");
if (searchInput && searchInput.value.trim()) {
params.set("q", searchInput.value.trim());
}
// Preserve relationship filter
if (
typeof currentTeamRelationshipFilter !== "undefined" &&
currentTeamRelationshipFilter &&
currentTeamRelationshipFilter !== "all"
) {
params.set("relationship", currentTeamRelationshipFilter);
}
const url = `${window.ROOT_PATH || ""}/admin/teams/partial?${params.toString()}`;
window.htmx.ajax("GET", url, {
target: "#unified-teams-list",
swap: "innerHTML",
});
}
}If the refreshTeamsList event won't be needed, we can remove it from the admin.js file.
There was a problem hiding this comment.
Thanks @gcgoncalves, let me check the dependency and I will make the change.
7eba08a to
e7bc224
Compare
Updates the HX-Trigger in admin_update_team to use 'refreshUnifiedTeamsList' instead of 'refreshTeamsList', ensuring the UI updates correctly after editing a team. Signed-off-by: Adnan Vahora <adnan.vahora1@motorolasolutions.com>
e7bc224 to
71bcfca
Compare
|
Thanks @settler-av for the fix and @gcgoncalves for the review! I've rebased the branch onto main and addressed the review feedback by also removing the now-unused Changes in this PR:
All tests pass (7171 passed). |
Updates the HX-Trigger in admin_update_team to use 'refreshUnifiedTeamsList' instead of 'refreshTeamsList', ensuring the UI updates correctly after editing a team. Signed-off-by: Adnan Vahora <adnan.vahora1@motorolasolutions.com> Co-authored-by: Adnan Vahora <adnan.vahora1@motorolasolutions.com>
🐛 Bug-fix PR
🔗 Related Issue
Closes #2691
📝 Summary
Updates the HTMX event trigger in the Team Edit modal to ensure the teams list refreshes correctly after an update. Previously, the UI would not update the table view because it was listening for a disparate event name.
🏷️ Type of Change
🔁 Reproduction Steps
🐞 Root Cause
The Python backend
admin_update_teamwas sending an HTMX trigger header namedrefreshTeamsList, but the frontend (HTMX/Alpine.js) is listening forrefreshUnifiedTeamsList. This mismatch caused the refresh event to be ignored.💡 Fix Description
Updated
admin.pyto send the correct event name:This aligns the backend trigger with the frontend event listener.
🧪 Verification
make lintmake testmake coverage✅ Checklist
make black isort pre-commit)