Skip to content

Commit ac0709e

Browse files
authored
Add browse when no queries are entered (#34)
* Add customization in Vue playground * Add browse * Add placeholderSearch option * Add documentation about placeholderSearch * Update tests
1 parent 43df64e commit ac0709e

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ const searchClient = instantMeiliSearch(
5353
"dc3fedaf922de8937fdea01f0a7d59557f1fd31832cb8440ce94231cfdde7f25",
5454
{
5555
hitsPerPage: 6, // default: 10
56-
limitPerRequest: 30 // default: 50
56+
limitPerRequest: 30, // default: 50
57+
placeholderSearch: false // default: true. Displays documents even when the query is empty.
5758
}
5859
);
5960
```

examples/express/tests/client.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ describe('Instant MeiliSearch Browser test', () => {
55

66
it('Should have generated a instant-meiisearch client and displayed', async () => {
77
await expect(page).toMatch(
8-
'{"client":{"cancelTokenSource":{"token":{"promise":{}}},"config":{"host":"http://localhost:7700","apiKey":"masterKey"}},"hitsPerPage":10,"limitPerRequest":50,"attributesToHighlight":["*"]}'
8+
'{"client":{"cancelTokenSource":{"token":{"promise":{}}},"config":{"host":"http://localhost:7700","apiKey":"masterKey"}},"hitsPerPage":10,"limitPerRequest":50,"attributesToHighlight":["*"],"placeholderSearch":true}'
99
)
1010
})
1111
})

playgrounds/vue/src/App.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
</template>
4141
</ais-hits>
4242

43-
<ais-pagination/>
43+
<ais-pagination :padding="4" />
4444
</div>
4545
</ais-instant-search>
4646
</div>
@@ -56,7 +56,11 @@ export default {
5656
return {
5757
searchClient: instantMeiliSearch(
5858
"https://demos.meilisearch.com",
59-
"dc3fedaf922de8937fdea01f0a7d59557f1fd31832cb8440ce94231cfdde7f25"
59+
"dc3fedaf922de8937fdea01f0a7d59557f1fd31832cb8440ce94231cfdde7f25",
60+
{
61+
hitsPerPage: 6,
62+
limitPerRequest: 100
63+
}
6064
)
6165
};
6266
}

src/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ export default function instantMeiliSearch(hostUrl, apiKey, options = {}) {
77
hitsPerPage: options.hitsPerPage || 10,
88
limitPerRequest: options.limitPerRequest || 50,
99
attributesToHighlight: ['*'],
10+
placeholderSearch: options.placeholderSearch !== false, // true by default
1011

1112
transformToMeiliSearchParams: function (params) {
1213
const searchInput = {
13-
q: params.query,
14+
q: this.placeholderSearch && params.query === '' ? null : params.query,
1415
facetsDistribution: params.facets.length ? params.facets : undefined,
1516
facetFilters: params.facetFilters,
1617
attributesToHighlight: this.attributesToHighlight,

0 commit comments

Comments
 (0)