fix(views): drop the selection whenever the view changes
Checked ids belong to the view they were made in. Carried into the trash they were LIVE entries while the trash bar offers Delete forever, so a purge could destroy rows that had never been trashed. The checkbox-less views were the visible symptom of the same problem; one rule replaces the special case.
This commit is contained in:
@@ -2288,20 +2288,23 @@ async function addTagToEntry(id, tag) {
|
||||
} catch (err) { toast(err.message, 'error'); }
|
||||
}
|
||||
|
||||
// Views that render no checkboxes: audit log, authenticator grid, vault health.
|
||||
const VIEWS_WITHOUT_SELECTION = ['audit', 'authenticator', 'health'];
|
||||
// A selection belongs to the view it was made in. Carrying it across is never
|
||||
// what the user meant, and between the list and the trash it is dangerous: the
|
||||
// checked ids are LIVE entries while the trash bar offers "Delete forever", so
|
||||
// a purge would hit rows that were never in the trash. Views without checkboxes
|
||||
// (health, authenticator, audit) were the visible symptom of the same problem.
|
||||
let selectionView = null;
|
||||
|
||||
function renderGrid() {
|
||||
if (state.view !== selectionView) {
|
||||
selectionView = state.view;
|
||||
state.checked.clear();
|
||||
}
|
||||
$('#contentTitle').textContent = viewTitle();
|
||||
// Re-apply the keyboard cursor after the grid re-renders. Defer one
|
||||
// tick so the new cards are in the DOM before we query for them.
|
||||
setTimeout(applyCursorHighlight, 0);
|
||||
|
||||
// A selection made in the list survived into these views, where nothing
|
||||
// shows what is selected — yet the batch bar still offered Delete, Move to
|
||||
// folder and Add tag on rows the user could no longer see.
|
||||
if (state.checked.size && VIEWS_WITHOUT_SELECTION.indexOf(state.view) !== -1)
|
||||
state.checked.clear();
|
||||
|
||||
// Audit log: read-only chronological feed, custom render.
|
||||
if (state.view === 'audit') {
|
||||
|
||||
Reference in New Issue
Block a user