Skip to content

Commit

Permalink
fix(templates): improve search and fix key issues (#8549)
Browse files Browse the repository at this point in the history
  • Loading branch information
danilowoz authored Aug 15, 2024
1 parent 706166d commit 7e89fdf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions packages/app/src/app/components/Create/CreateBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,10 @@ export const CreateBox: React.FC<CreateBoxProps> = ({
if (searchQuery) {
filteredTemplates = filteredTemplates.filter(template => {
return (
template.title?.toLowerCase().includes(searchQuery) ||
template.tags.some(tag => tag.includes(searchQuery))
template.title?.toLowerCase().includes(searchQuery.toLowerCase()) ||
template.tags.some(tag =>
tag.toLowerCase().includes(searchQuery.toLowerCase())
)
);
});
}
Expand Down Expand Up @@ -272,13 +274,15 @@ export const CreateBox: React.FC<CreateBoxProps> = ({
<TemplateList
searchQuery={searchQuery}
title="Recently used"
key="Recently used"
templates={recentlyUsedTemplates}
onSelectTemplate={selectTemplate}
onOpenTemplate={openTemplate}
/>
)}
<TemplateList
title="Popular"
key="Popular"
searchQuery={searchQuery}
templates={featuredTemplates}
onSelectTemplate={selectTemplate}
Expand All @@ -287,6 +291,7 @@ export const CreateBox: React.FC<CreateBoxProps> = ({
</>
) : (
<TemplateList
key={filters.join()}
searchQuery={searchQuery}
templates={filteredTemplates}
onSelectTemplate={selectTemplate}
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/app/components/Create/TemplateList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const TemplateList = ({
<TemplateGrid>
{templates.map(template => (
<TemplateCard
key={template.id + template.browserSandboxId}
key={template.id + template.browserSandboxId + template.title}
template={template}
onSelectTemplate={onSelectTemplate}
onOpenTemplate={onOpenTemplate}
Expand Down

0 comments on commit 7e89fdf

Please sign in to comment.