From b54da5c64cea05f4644c19ec8e5853a942133c6b Mon Sep 17 00:00:00 2001 From: William Mantly Date: Tue, 28 Jul 2026 18:35:15 -0400 Subject: [PATCH] Fix resource modal's LDAP-groups autocomplete going empty after first open (#122) loadLdapGroups()'s cache guard (if (ldapGroupsCache) return;) also skipped the DOM-repopulation step on every call after the first, but #ldap-groups-datalist is rebuilt fresh and empty on every app.modal.open() -- so the "Associated LDAP Groups" tab's group-name autocomplete silently lost all its suggestions starting on the second Add/Edit. Now the fetch stays cached, but the datalist is always repopulated. Verified live: opened the resource modal on Proxy twice in a row, confirmed the datalist has all 17 options both times (would have been 0 on the second open with the old code). --- CHANGELOG.md | 5 +++++ nodejs/package.json | 2 +- nodejs/views/directory.ejs | 11 ++++++++--- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b0cf24..15330e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ All notable changes to this project are documented here. Format loosely follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/); versions correspond to git tags (`vX.Y.Z`) and `nodejs/package.json`'s `version`. +## [1.8.1] - 2026-07-28 + +### Fixed +- **The resource modal's "Associated LDAP Groups" autocomplete went empty after the first Add/Edit** — `loadLdapGroups()`'s fetch-once cache guard (`if (ldapGroupsCache) return;`) also skipped repopulating the `` on every call after the first, but the modal body (including that ``) is rebuilt fresh and empty on every `app.modal.open()`. Now the fetch is still cached, but the datalist is always repopulated. + ## [1.8.0] - 2026-07-28 ### Added diff --git a/nodejs/package.json b/nodejs/package.json index 9c13b84..502e514 100755 --- a/nodejs/package.json +++ b/nodejs/package.json @@ -1,6 +1,6 @@ { "name": "t42-sso-manager", - "version": "1.8.0", + "version": "1.8.1", "description": "A very simple LDAP management and SSO system", "author": [ { diff --git a/nodejs/views/directory.ejs b/nodejs/views/directory.ejs index d3ca838..e9aa7b6 100644 --- a/nodejs/views/directory.ejs +++ b/nodejs/views/directory.ejs @@ -563,10 +563,15 @@ var ldapGroupsCache = null; async function loadLdapGroups() { - if (ldapGroupsCache) return; try { - const res = await app.api.get('group'); - ldapGroupsCache = res.results; + if (!ldapGroupsCache) { + const res = await app.api.get('group'); + ldapGroupsCache = res.results; + } + // Re-populate every call, not just the first -- #ldap-groups-datalist + // is rebuilt fresh (empty) on every app.modal.open(), so returning + // early here on a cache hit left the second and later modal opens + // with no autocomplete options at all. const $datalist = $('#ldap-groups-datalist'); $datalist.empty(); for (const cn of ldapGroupsCache) {