The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
fix(command palette): show different skeleton when no recent items (#64929)
Uladzimir Havenchykc396990a9833
diff --git a/frontend/src/metabase/palette/components/PaletteResultItem.unit.spec.tsx b/frontend/src/metabase/palette/components/PaletteResultItem.unit.spec.tsxindex 57cb049b0b2..de31a9f4f60 100644--- a/frontend/src/metabase/palette/components/PaletteResultItem.unit.spec.tsx+++ b/frontend/src/metabase/palette/components/PaletteResultItem.unit.spec.tsx@@ -69,6 +69,8 @@ const setupInList = ({ item }: { item: Partial<PaletteActionImpl> }) => {component={() => (<PaletteResultListitems={items.map((item) => mockPaletteActionImpl(item))}+ maxHeight={580}+ minHeight={220}renderItem={({item,active,diff --git a/frontend/src/metabase/palette/components/PaletteResults.tsx b/frontend/src/metabase/palette/components/PaletteResults.tsxindex f206b3a9362..c45f19ab513 100644--- a/frontend/src/metabase/palette/components/PaletteResults.tsx+++ b/frontend/src/metabase/palette/components/PaletteResults.tsx@@ -5,11 +5,13 @@ import { Link } from "react-router";import { useKeyPressEvent } from "react-use";import { t } from "ttag";+import NoResults from "assets/img/no_results.svg";import { trackSearchClick } from "metabase/search/analytics";import {Flex,Group,Icon,+ Image,Skeleton,Stack,type StackProps,@@ -79,7 +81,11 @@ export const PaletteResults = ({);});- if (processedResults.length === 0) {+ if (processedResults.length === 0 && searchTerm.length === 0) {+ return <PaletteEmptyState />;+ }++ if (processedResults.length === 0 && searchTerm.length > 0) {return <PaletteResultsSkeleton />;}@@ -88,6 +94,7 @@ export const PaletteResults = ({<PaletteResultListitems={processedResults} // items needs to be a stable reference, otherwise the activeIndex will constantly be hijackedmaxHeight={530}+ minHeight={searchTerm.length === 0 ? 280 : 0}renderItem={({ item, active }) => {const isFirst = processedResults[0] === item;@@ -153,6 +160,20 @@ export const PaletteResults = ({);};+function PaletteEmptyState() {+ return (+ <Stack align="center" justify="center" py="6rem" px="2rem" gap={0}>+ <Image src={NoResults} alt="no results" w={115} h={65} />+ <Text c="text-medium" fw={700} mt="xl">+ {t`No recent items`}+ </Text>+ <Text c="text-light" size="sm" mt="xs" ta="center">+ {t`Items you've recently viewed will appear here.`}+ </Text>+ </Stack>+ );+}+function PaletteResultsSkeleton() {return (<Stack my="3.75rem" mx="4rem">diff --git a/frontend/src/metabase/palette/components/PaletteResultsList.tsx b/frontend/src/metabase/palette/components/PaletteResultsList.tsxindex 77950aeac56..14243a9ec71 100644--- a/frontend/src/metabase/palette/components/PaletteResultsList.tsx+++ b/frontend/src/metabase/palette/components/PaletteResultsList.tsx@@ -29,7 +29,8 @@ interface RenderParams<T = PaletteActionImpl | string> {interface PaletteResultListProps {items: (PaletteActionImpl | string)[];renderItem: (params: RenderParams) => React.ReactElement;- maxHeight?: number;+ maxHeight: number;+ minHeight: number;}export const PaletteResultList = (props: PaletteResultListProps) => {@@ -149,7 +150,8 @@ export const PaletteResultList = (props: PaletteResultListProps) => {<divref={parentRef}style={{- maxHeight: props.maxHeight || 400,+ maxHeight: props.maxHeight,+ minHeight: props.minHeight,overflow: "auto",}}>