diff --git a/cmd/server/tests/filter_builder_test.go b/cmd/server/tests/filter_builder_test.go index 653cb731..f08943a1 100644 --- a/cmd/server/tests/filter_builder_test.go +++ b/cmd/server/tests/filter_builder_test.go @@ -516,6 +516,16 @@ func TestFilterSuggestionsUnderRules(t *testing.T) { require.Equal(t, http.StatusOK, status) assert.NotContains(t, valuesOf(results), "Amara Voss", "zero-match values never offered") + // BROWSE (the user's click-the-box case): a blank typed query lists + // the field's top values UNDER the other rules — "assign an author, + // click publisher, see their publishers" without typing anything. + // The wire sends a single space as the sentinel. + status, results = suggest("genre", " ", qfAll(qfRule("author", "contains", "Quill"))) + require.Equal(t, http.StatusOK, status) + assert.Contains(t, valuesOf(results), "fantasy", "browse shows the field's values under the rules") + assert.NotContains(t, valuesOf(results), "spacewestern", "zero-match values never offered") + assert.NotContains(t, valuesOf(results), "history", "values outside the rules never offered") + // Library field menu: visibility-scoped, id values + name display // (this test's fixture libraries are named "Test Builder Sug …"). status, results = suggest("library", "Test Builder", "") diff --git a/internal/services/filter_query.go b/internal/services/filter_query.go index 19f6cb72..91593f71 100644 --- a/internal/services/filter_query.go +++ b/internal/services/filter_query.go @@ -863,6 +863,10 @@ func (s *SearchService) ComposedFieldValues(ctx context.Context, p ComposedSugge if p.Limit <= 0 { p.Limit = 50 } + // A blank typed query means BROWSE (the user clicked the value box + // to see what exists under the other rules) — not a similarity + // filter for a single space. + p.Typed = strings.TrimSpace(p.Typed) b := newFilterBuilder(p.UserID) typedBind := b.bind(p.Typed) diff --git a/templates/bookshelf.templ b/templates/bookshelf.templ index 4aabbb87..b647a3b5 100644 --- a/templates/bookshelf.templ +++ b/templates/bookshelf.templ @@ -183,9 +183,7 @@ templ BookShelf(