Skip to content

Commit 83e2c1f

Browse files
authored
fix: quick search T1478, T1396 (#2354)
* fix: update settings title translation in QuickAction component * fix: space search * fix: update QuickAction component to use id as value and add keywords for accessibility * fix: enhance CommandDialog and Command components with filtering capabilities
1 parent 9b38ba6 commit 83e2c1f

File tree

14 files changed

+84
-17
lines changed

14 files changed

+84
-17
lines changed

apps/nestjs-backend/src/types/i18n.generated.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,9 @@ export type I18nTranslations = {
289289
};
290290
"settings": {
291291
"title": string;
292+
"personal": {
293+
"title": string;
294+
};
292295
"back": string;
293296
"account": {
294297
"title": string;

apps/nextjs-app/src/features/app/blocks/base/base-side-bar/QuickAction.tsx

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,19 @@ export const QuickAction = ({ children }: React.PropsWithChildren) => {
7070
</kbd>
7171
)}
7272
</Button>
73-
<CommandDialog open={open} onOpenChange={setOpen}>
73+
<CommandDialog
74+
open={open}
75+
onOpenChange={setOpen}
76+
commandProps={{
77+
filter: (value, search, keywords) => {
78+
const searchLower = search.toLowerCase();
79+
if (keywords?.some((keyword) => keyword.toLowerCase().includes(searchLower))) {
80+
return 1;
81+
}
82+
return 0;
83+
},
84+
}}
85+
>
7486
<CommandInput placeholder={t('common:quickAction.placeHolder')} />
7587
<CommandList>
7688
<CommandEmpty>{t('common:noResult')}</CommandEmpty>
@@ -105,7 +117,8 @@ export const QuickAction = ({ children }: React.PropsWithChildren) => {
105117
<CommandItem
106118
className="flex gap-2"
107119
key={id}
108-
value={name}
120+
value={id}
121+
keywords={[name]}
109122
onSelect={() => {
110123
setOpen(false);
111124
if (url) {
@@ -136,6 +149,7 @@ export const QuickAction = ({ children }: React.PropsWithChildren) => {
136149
theme.setTheme('light');
137150
}}
138151
value={t('common:settings.setting.light')}
152+
keywords={[t('common:settings.setting.light')]}
139153
>
140154
<Sun className="size-4" />
141155
<span>{t('common:settings.setting.light')}</span>
@@ -147,6 +161,7 @@ export const QuickAction = ({ children }: React.PropsWithChildren) => {
147161
theme.setTheme('dark');
148162
}}
149163
value={t('common:settings.setting.dark')}
164+
keywords={[t('common:settings.setting.dark')]}
150165
>
151166
<Moon className="size-4" />
152167
<span>{t('common:settings.setting.dark')}</span>
@@ -158,24 +173,26 @@ export const QuickAction = ({ children }: React.PropsWithChildren) => {
158173
theme.setTheme('system');
159174
}}
160175
value={t('common:settings.setting.system')}
176+
keywords={[t('common:settings.setting.system')]}
161177
>
162178
<LaptopIcon className="size-4" />
163179
<span>{t('common:settings.setting.system')}</span>
164180
</CommandItem>
165181
</CommandGroup>
166182
<CommandSeparator />
167183
{!isAnonymous && !isTemplate && (
168-
<CommandGroup heading={t('common:settings.title')}>
184+
<CommandGroup heading={t('common:settings.nav.settings')}>
169185
<CommandItem
170186
className="flex gap-2"
171187
onSelect={() => {
172188
setOpen(false);
173189
setting.setOpen(true);
174190
}}
175-
value={t('common:settings.title')}
191+
value={t('common:settings.personal.title')}
192+
keywords={[t('common:settings.personal.title')]}
176193
>
177194
<Settings className="size-4" />
178-
<span>{t('common:settings.title')}</span>
195+
<span>{t('common:settings.personal.title')}</span>
179196
</CommandItem>
180197
</CommandGroup>
181198
)}

apps/nextjs-app/src/features/app/blocks/space/space-side-bar/SpaceSwitcher.tsx

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import {
2929
PopoverTrigger,
3030
} from '@teable/ui-lib/shadcn';
3131
import Link from 'next/link';
32+
import { useParams } from 'next/navigation';
3233
import { useRouter } from 'next/router';
3334
import { useTranslation } from 'next-i18next';
3435
import { useMemo, useState } from 'react';
@@ -89,14 +90,7 @@ export const SpaceSwitcher = () => {
8990

9091
const pinMap = usePinMap();
9192
const { spaceList } = useSpaceList();
92-
const currentSpaceId = router.query.spaceId as string | undefined;
93-
94-
const handleOpenChange = (isOpen: boolean) => {
95-
setOpen(isOpen);
96-
if (isOpen) {
97-
setHighlightedValue(currentSpaceId);
98-
}
99-
};
93+
const { spaceId: currentSpaceId } = useParams<{ spaceId: string }>();
10094

10195
const { data: subscriptionList } = useQuery({
10296
queryKey: ['subscription-summary-list'],
@@ -134,6 +128,13 @@ export const SpaceSwitcher = () => {
134128
},
135129
});
136130

131+
const handleOpenChange = (isOpen: boolean) => {
132+
setOpen(isOpen);
133+
if (isOpen) {
134+
setHighlightedValue(currentSpaceId);
135+
}
136+
};
137+
137138
const handleCreateSpace = () => {
138139
const name =
139140
spaceName.trim() ||
@@ -170,7 +171,17 @@ export const SpaceSwitcher = () => {
170171
</PopoverTrigger>
171172

172173
<PopoverContent className="min-w-[360px] p-0" align="start">
173-
<Command value={highlightedValue} onValueChange={setHighlightedValue}>
174+
<Command
175+
value={highlightedValue}
176+
onValueChange={setHighlightedValue}
177+
filter={(value, search, keywords) => {
178+
const searchLower = search.toLowerCase();
179+
if (keywords?.some((keyword) => keyword.toLowerCase().includes(searchLower))) {
180+
return 1;
181+
}
182+
return 0;
183+
}}
184+
>
174185
<div className="px-4 pb-2 pt-4">
175186
<p className="pb-2 text-sm font-semibold ">
176187
{t('space:allSpaces')} ({spaceList?.length || 0})
@@ -195,6 +206,7 @@ export const SpaceSwitcher = () => {
195206
<CommandItem
196207
key={space.id}
197208
value={space.id}
209+
keywords={[space.name]}
198210
onSelect={() => handleSelectSpace(space)}
199211
className={cn('group flex items-center gap-2 rounded-md h-10')}
200212
>

packages/common-i18n/src/locales/de/common.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@
8888
},
8989
"settings": {
9090
"title": "Einstellungen",
91+
"personal": {
92+
"title": "Persönliche Einstellungen"
93+
},
9194
"back": "Zurück zum Start",
9295
"account": {
9396
"title": "Mein Profil",

packages/common-i18n/src/locales/en/common.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@
101101
},
102102
"settings": {
103103
"title": "Instance settings",
104+
"personal": {
105+
"title": "Personal settings"
106+
},
104107
"templateAdmin": {
105108
"title": "Template admin",
106109
"noData": "No data",

packages/common-i18n/src/locales/es/common.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@
8888
},
8989
"settings": {
9090
"title": "Configuración",
91+
"personal": {
92+
"title": "Configuración personal"
93+
},
9194
"back": "Volver al inicio",
9295
"account": {
9396
"title": "Mi perfil",

packages/common-i18n/src/locales/fr/common.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@
8181
},
8282
"settings": {
8383
"title": "Paramètres",
84+
"personal": {
85+
"title": "Paramètres personnels"
86+
},
8487
"back": "Retour à l'accueil",
8588
"account": {
8689
"title": "Mon profil",

packages/common-i18n/src/locales/it/common.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@
8888
},
8989
"settings": {
9090
"title": "Impostazioni",
91+
"personal": {
92+
"title": "Impostazioni personali"
93+
},
9194
"back": "Torna alla home",
9295
"account": {
9396
"title": "Il mio profilo",

packages/common-i18n/src/locales/ja/common.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@
8080
},
8181
"settings": {
8282
"title": "設定",
83+
"personal": {
84+
"title": "個人設定"
85+
},
8386
"back": "ホームに戻る",
8487
"account": {
8588
"title": "プロフィール",

packages/common-i18n/src/locales/ru/common.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@
8181
},
8282
"settings": {
8383
"title": "Настройки",
84+
"personal": {
85+
"title": "Личные настройки"
86+
},
8487
"back": "Назад на главную",
8588
"account": {
8689
"title": "Мой профиль",

0 commit comments

Comments
 (0)