fix(ui): address row actions by the cached record, not the filtered row number - #227
Merged
Merged
Conversation
…ow number Three tables rebuild their list with .filter() and then tag every row button with the index *inside the searched list*, while the handlers resolve that index against the full cached array: #api-keys copyKey / renameKey / deleteKey -> Live.apiKeys[i] #model-body editModelRow / deleteModel -> Live.adminModels[i] #dept-body openDeptForm / deleteDept -> Live.departments[i] So as soon as the search box hides one earlier row, a button acts on a different record than the row it sits in: the delete removed the wrong API key / model / department, copy handed out another key's secret, and the edit form opened with another record's values. Both correct idioms already exist in the same file — #emp-body tags rows with users.indexOf(u) and #ops-body with u.id — these three tables were simply never updated when their search boxes were added (#79, #80, #97). - api-keys: carry the cached index through the mapping, add data-key-row and resolve the row by that locator instead of nth-child - model-body / dept-body: derive the locator with indexOf, mirroring #emp-body - bump the app.js cache-bust
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Searching a table rebuilt its rows with
Array.prototype.filter, and the row buttons were then tagged with the index inside the searched list — while the click handlers resolve that index against the full cached array:#api-keys(Settings)Live.apiKeys[i]#model-body(Admin ▸ Models)Live.adminModels[i]#dept-body(Admin ▸ Departments)Live.departments[i]So once the search box hides one earlier row, a button acts on a different record than the row it sits in. Reproduced in a real-DOM harness (jsdom running
ui/index.html+ the four real scripts, onlyfetchstubbed): searchgammain Settings, click that row's delete →DELETE /api/api-keys/11(alpha) instead of/33; the inline rename PATCHes/api/api-keys/11; copy puts alpha's full secret on the clipboard. Same for the model and department tables (edit form prefilled with another record's values; delete hits the wrong id).Two correct idioms already exist in the very same file —
#emp-bodytags rows withusers.indexOf(u)and#ops-bodytags them withu.id— so this is drift introduced when the search boxes were wired up (#79,#80,#97), not a design decision.Related Issue
Changes
ui/js/app.js#api-keys: carry the cached index through the mapping (idx), adddata-key-row, and resolve the row inrenameKeyby that locator instead oftr:nth-child(i+1).#model-body/#dept-body: derive the locator withindexOfon the cached array, mirroring#emp-body.ui/index.html: bump theapp.jscache-bust (?v=20260914-4).config/config.example.tomlchange (no new data/config keys). No new i18n keys.Tests
cargo test— 235 passed, 0 failed (unchanged baseline)cargo fmt --check— cleancargo clippy --all-targets -- -D warnings— cleanNew/updated unit tests — not applicable: this repo has no JS test infrastructure and
app.jsbehaviour is not reachable fromcargo test. Verified instead with a real-DOM (jsdom) harness drivingui/index.html+ the four real scripts, plus an A/B run:app.jsatorigin/main(pre-change)The three partial reverts are pairwise disjoint and together account for exactly the pre-change failure set; the unfiltered-control checks (
A2/B2/C2) stay green in every leg. The one remaining red check in the fixed tree is an unrelated defect (the model form's submit button never fires its request — nestedwithLoadingbusy-guard inconfirmModel); it fails identically before and after this change and is deliberately left for its own PR.Checklist
fix/)