Skip to content

Commit 326ebd0

Browse files
committed
fix(ui): close drilldown stack before following FK links
navigateToLink was switching the top-level tab without closing the detail stack, so the user stayed trapped in the detail view with only a status message. Now it calls closeAllDetails() first so the link actually lands on the target tab. Also dropped the noisy "Followed link to ID N" status message -- cursor placement is sufficient feedback.
1 parent ca374a6 commit 326ebd0

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

internal/app/detail_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,3 +635,24 @@ func TestDrilldownHint(t *testing.T) {
635635
"kind=%v title=%s", tt.kind, tt.title)
636636
}
637637
}
638+
639+
func TestNavigateToLinkClosesDetailStack(t *testing.T) {
640+
m := newTestModelWithDemoData(t, 42)
641+
m.active = tabIndex(tabVendors)
642+
643+
vendors, err := m.store.ListVendors(false)
644+
require.NoError(t, err)
645+
require.NotEmpty(t, vendors)
646+
647+
// Drill into vendor quotes.
648+
require.NoError(t, m.openVendorQuoteDetail(vendors[0].ID, vendors[0].Name))
649+
require.True(t, m.inDetail())
650+
651+
// Follow the Project link from the detail view.
652+
link := &columnLink{TargetTab: tabProjects}
653+
require.NoError(t, m.navigateToLink(link, 1))
654+
655+
// Detail stack should be fully collapsed and we should be on Projects.
656+
assert.False(t, m.inDetail(), "detail stack should be closed after navigateToLink")
657+
assert.Equal(t, tabIndex(tabProjects), m.active)
658+
}

internal/app/model.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -925,18 +925,18 @@ func (m *Model) startCellOrFormEdit() error {
925925
return tab.Handler.InlineEdit(m, meta.ID, col)
926926
}
927927

928-
// navigateToLink switches to the target tab and selects the row matching the FK.
928+
// navigateToLink closes any open drilldown stack, switches to the target tab,
929+
// and selects the row matching the FK.
929930
func (m *Model) navigateToLink(link *columnLink, targetID uint) error {
931+
m.closeAllDetails()
930932
m.switchToTab(tabIndex(link.TargetTab))
931933
tab := m.activeTab()
932934
if tab == nil {
933935
return fmt.Errorf("target tab not found")
934936
}
935-
if selectRowByID(tab, targetID) {
936-
m.setStatusInfo(fmt.Sprintf("Followed link to ID %d.", targetID))
937-
return nil
937+
if !selectRowByID(tab, targetID) {
938+
m.setStatusError(fmt.Sprintf("Linked item %d not found (deleted?).", targetID))
938939
}
939-
m.setStatusError(fmt.Sprintf("Linked item %d not found (deleted?).", targetID))
940940
return nil
941941
}
942942

0 commit comments

Comments
 (0)