Trigger mention dialog after a single character (#3644)
* Limit mentions to a single character * Adjust test
This commit is contained in:
committed by
GitHub
parent
298e0977de
commit
2f44ae2a7e
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div
|
||||
v-show="(query?.length || 0) >= 3"
|
||||
v-show="(query?.length || 0) >= 1"
|
||||
class="bg-foundation text-foreground rounded shadow-md p-2"
|
||||
>
|
||||
<ul>
|
||||
@@ -14,7 +14,7 @@
|
||||
</li>
|
||||
</template>
|
||||
<template v-else>
|
||||
<li>Couldn't find anything 🤷</li>
|
||||
<li>Couldn't find anyone</li>
|
||||
</template>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
@@ -20,7 +20,7 @@ export type MentionData = { label: string; id: string }
|
||||
|
||||
const suggestionOptions: Omit<SuggestionOptions<SuggestionOptionsItem>, 'editor'> = {
|
||||
async items({ query, editor }) {
|
||||
if (query.length < 3) return []
|
||||
if (query.length < 1) return []
|
||||
|
||||
const state = editor.storage.editorInstanceState as EditorInstanceStateStorage
|
||||
const projectId = state.state.projectId
|
||||
|
||||
@@ -139,8 +139,8 @@ export = {
|
||||
},
|
||||
|
||||
async users(_parent, args) {
|
||||
if (args.input.query.length < 3)
|
||||
throw new BadRequestError('Search query must be at least 3 characters.')
|
||||
if (args.input.query.length < 1)
|
||||
throw new BadRequestError('Search query must be at least 1 character.')
|
||||
|
||||
if ((args.input.limit || 0) > 100)
|
||||
throw new BadRequestError(
|
||||
|
||||
@@ -199,11 +199,11 @@ describe('Users @graphql', () => {
|
||||
])
|
||||
})
|
||||
|
||||
it('doesnt work with less than 3 characters', async () => {
|
||||
it('doesnt work with less than 1 character', async () => {
|
||||
const res = await search({
|
||||
query: 'fi'
|
||||
query: ''
|
||||
})
|
||||
expect(res).to.haveGraphQLErrors('Search query must be at least 3 characters')
|
||||
expect(res).to.haveGraphQLErrors('Search query must be at least 1 character')
|
||||
})
|
||||
|
||||
it('doesnt work with more than 100 items', async () => {
|
||||
|
||||
Reference in New Issue
Block a user