Skip to content

Commit d16ab12

Browse files
Merge pull request #37 from Spacecraft-Software/detail-pane-scroll
feat(vault-tui): scroll the detail pane to keep the field cursor visible
2 parents 2a127f9 + d9faa8c commit d16ab12

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ range may break in any release.
1010

1111
### Added
1212

13+
- **Scrolling detail pane.** The detail pane now scrolls to keep the focused
14+
field visible — the granular identity view is ~18 fields and could overflow a
15+
shorter terminal. Reuses the form's `scroll_offset`; only the detail-focused
16+
view scrolls (browsing is unchanged).
17+
1318
- **Granular identity field selectors.** 16 new `--field` selectors expose every
1419
identity field individually — `identity-{title,first-name,middle-name,
1520
last-name,username,company,ssn,passport,license,address1,address2,address3,

crates/vault-tui/src/ui.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,19 @@ fn render_detail(frame: &mut Frame, app: &App, area: Rect) {
316316
lines
317317
},
318318
);
319+
// Scroll to keep the focused field visible (the identity detail can be
320+
// taller than the pane). The body is [Name, Type, <fields…>, Folder, Id,
321+
// "", hint], so the cursor field's line is `2 + detail_field`. Only the
322+
// detail-focused path scrolls; every other state keeps offset 0.
323+
let focused_line = if app.detail_focused() {
324+
2 + app.detail_field
325+
} else {
326+
0
327+
};
328+
let offset = scroll_offset(focused_line, (area.height.saturating_sub(2)) as usize);
319329
let para = Paragraph::new(lines)
320330
.block(pane_block("Detail", app.detail_focused()))
331+
.scroll((u16::try_from(offset).unwrap_or(u16::MAX), 0))
321332
.wrap(Wrap { trim: true });
322333
frame.render_widget(para, area);
323334
}

0 commit comments

Comments
 (0)