detail: optional bucket-switch on open from search / link
New toggle under Settings → Behavior → Interactions: "Switch to card's bucket on open (search / link)". When enabled, openDetail calls activateBucket(card.bucket_id) so the board and bucket bar update to show the card's context. Skipped when already on 'all' or the correct bucket. Default off. Uses activateBucket() (from buckets.js) instead of raw state assignment so the bucket-bar highlight tracks the switch. Tests: two cases — setting on switches activeBucket + verifies the bucket-tab.active in the bar matches; setting off leaves the bucket unchanged. Both create/delete probe cards in try/finally and restore the setting + activeBucket in afterEach. Bumps to 1.9.27. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
6fa42eb267
commit
c934673c4a
6 files changed
+96
-3
No files matched your search
@@ -5,6 +5,7 @@ import { state, parseTags, tagChipHtml, getChildren, getGroupCards, getRecent, m
|
||||
import { renderMd, stripMd, firstImage, addCodeCopyButtons, formatTodoItems } from './markdown.js';
|
||||
import { pushCardDelete, pushCardEdit, snapshotCard } from './undo.js';
|
||||
import { showDialog } from './dialog.js';
|
||||
import { activateBucket } from './buckets.js';
|
||||
|
||||
const detail = $('detail');
|
||||
const scroll = $('detail-scroll');
|
||||
@@ -57,6 +58,18 @@ export function openDetail(id, options = {}) {
|
||||
if (!card) return;
|
||||
markRecent(id);
|
||||
|
||||
// Optional: switch the board to the card's bucket so the user
|
||||
// sees context. Only when opened via search, wikilink, or
|
||||
// programmatic call — not when the user clicked a board card
|
||||
// (they're already in the right bucket). Gated by a setting
|
||||
// under Behavior → Interactions.
|
||||
if (card.bucket_id
|
||||
&& localStorage.getItem('hyprcrd-open-switches-bucket') === '1'
|
||||
&& state.activeBucket !== 'all'
|
||||
&& String(state.activeBucket) !== String(card.bucket_id)) {
|
||||
activateBucket(card.bucket_id);
|
||||
}
|
||||
|
||||
const el = $('board')?.querySelector(`[data-id="${id}"]`);
|
||||
if (el) el.style.borderBottom = `3px solid ${card.color}`;
|
||||
|
||||
|
||||
@@ -450,6 +450,7 @@ function initBehaviorSettings() {
|
||||
'setting-show-done-badge': { key: 'hyprcrd-show-done-badge', def: '1' },
|
||||
'setting-confirm-delete': { key: 'hyprcrd-confirm-delete', def: '1' },
|
||||
'setting-auto-save': { key: 'hyprcrd-auto-save', def: '0' },
|
||||
'setting-open-switches-bucket': { key: 'hyprcrd-open-switches-bucket', def: '0' },
|
||||
};
|
||||
for (const [id, cfg] of Object.entries(selects)) {
|
||||
const el = $(id);
|
||||
|
||||
Reference in new issue
Block a user