Skip to content

Commit 91bd387

Browse files
mirekmcursoragent
andauthored
Variant list nudges (#6768)
* Fix invisible placeholders on variant search inputs. Macaw Input defaults to a transparent placeholder; use InputWithPlaceholder so the sibling list and variants grid search fields show their labels. Co-authored-by: Cursor <cursoragent@cursor.com> * Hide variants search bar when the product has no variants. Wire through the existing totalCount and skip the browse toolbar for empty products, while keeping it visible during an active search so zero-hit queries can still be cleared. Co-authored-by: Cursor <cursoragent@cursor.com> * Remove changeset for variant list UX tweaks. Co-authored-by: Cursor <cursoragent@cursor.com> * Tighten variants empty-state spacing and header padding Drop the empty-grid top padding and the header right-padding override so the bar matches Media, and avoid flashing the browse toolbar while totalCount is still unknown. --------- Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 0bf4beb commit 91bd387

6 files changed

Lines changed: 26 additions & 15 deletions

File tree

src/components/Datagrid/Datagrid.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ export const Datagrid = ({
706706
</div>
707707
</>
708708
) : (
709-
<Box padding={6}>
709+
<Box paddingX={6} paddingBottom={6}>
710710
<Placeholder>
711711
<span data-test-id="empty-data-grid-text">{emptyText}</span>
712712
</Placeholder>

src/components/InputWithPlaceholder/InputWithPlaceholder.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import { Input as MacawInput } from "@saleor/macaw-ui-next";
2+
import clsx from "clsx";
23
import { type ComponentProps, forwardRef } from "react";
34

45
import styles from "./InputWithPlaceholder.module.css";
56

67
export const InputWithPlaceholder = forwardRef<HTMLInputElement, ComponentProps<typeof MacawInput>>(
7-
(props, ref) => {
8-
return <MacawInput className={styles.inputWithPlaceholder} {...props} ref={ref} />;
8+
({ className, ...props }, ref) => {
9+
return (
10+
<MacawInput {...props} className={clsx(styles.inputWithPlaceholder, className)} ref={ref} />
11+
);
912
},
1013
);
1114

src/products/components/ProductVariantNavigation/ProductVariantNavigation.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { borderHeight, savebarHeight, topBarHeight } from "@dashboard/components/AppLayout/consts";
22
import { DashboardCard } from "@dashboard/components/Card";
33
import { Divider } from "@dashboard/components/Divider";
4+
import { InputWithPlaceholder } from "@dashboard/components/InputWithPlaceholder/InputWithPlaceholder";
45
import useNavigator from "@dashboard/hooks/useNavigator";
56
import { sectionNames } from "@dashboard/intl";
67
import {
@@ -10,7 +11,7 @@ import {
1011
import { productVariantAddUrl } from "@dashboard/products/urls";
1112
import { closestCenter, DndContext } from "@dnd-kit/core";
1213
import { SortableContext, verticalListSortingStrategy } from "@dnd-kit/sortable";
13-
import { Box, Button, Input, Skeleton, Text } from "@saleor/macaw-ui-next";
14+
import { Box, Button, Skeleton, Text } from "@saleor/macaw-ui-next";
1415
import {
1516
type ChangeEvent,
1617
type CSSProperties,
@@ -195,7 +196,7 @@ export const ProductVariantNavigation = ({
195196
flexShrink="0"
196197
>
197198
<Box flexGrow="1" __minWidth={0}>
198-
<Input
199+
<InputWithPlaceholder
199200
size="small"
200201
value={search}
201202
onChange={handleSearchChange}

src/products/components/ProductVariants/ProductVariants.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ export const ProductVariants = ({
9494
onVariantsNextPage,
9595
onVariantsPreviousPage,
9696
variantsRangeLabel,
97+
variantsTotalCount = null,
9798
variantsLoading = false,
9899
pendingVariantDeleteCount = 0,
99100
variantAttributes,
@@ -448,6 +449,7 @@ export const ProductVariants = ({
448449
onVariantsNextPage={onVariantsNextPage}
449450
onVariantsPreviousPage={onVariantsPreviousPage}
450451
variantsRangeLabel={variantsRangeLabel}
452+
variantsTotalCount={variantsTotalCount}
451453
onGuardUnsavedAction={guardAddedRowsThen}
452454
selectedCount={selectedCount}
453455
onDeleteSelected={handleBulkDeleteSelected}
@@ -469,6 +471,7 @@ export const ProductVariants = ({
469471
onVariantsNextPage,
470472
onVariantsPreviousPage,
471473
variantsRangeLabel,
474+
variantsTotalCount,
472475
guardAddedRowsThen,
473476
selectedCount,
474477
handleBulkDeleteSelected,

src/products/components/ProductVariants/components/ProductVariantsHeader.module.css

Lines changed: 0 additions & 4 deletions
This file was deleted.

src/products/components/ProductVariants/components/ProductVariantsHeader.tsx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
import { Header as DatagridHeader } from "@dashboard/components/Datagrid/components/Header";
22
import { type DatagridRenderHeaderProps } from "@dashboard/components/Datagrid/Datagrid";
33
import { iconSize, iconStrokeWidthBySize } from "@dashboard/components/icons";
4+
import { InputWithPlaceholder } from "@dashboard/components/InputWithPlaceholder/InputWithPlaceholder";
45
import { type VariantAttributeFragment } from "@dashboard/graphql";
56
import useNavigator from "@dashboard/hooks/useNavigator";
67
import { productVariantAddUrl } from "@dashboard/products/urls";
78
import { productTypeUrl } from "@dashboard/productTypes/urls";
8-
import { Box, Button, Input, Text, Tooltip } from "@saleor/macaw-ui-next";
9+
import { Box, Button, Text, Tooltip } from "@saleor/macaw-ui-next";
910
import { ChevronLeft, ChevronRight, CopyPlus } from "lucide-react";
1011
import { useCallback } from "react";
1112
import { defineMessages, FormattedMessage, useIntl } from "react-intl";
1213
import { Link } from "react-router-dom";
1314

1415
import messages from "../messages";
15-
import styles from "./ProductVariantsHeader.module.css";
1616

1717
const localMessages = defineMessages({
1818
generatorRequiresConfig: {
@@ -153,6 +153,8 @@ interface ProductVariantsHeaderProps extends DatagridRenderHeaderProps {
153153
onVariantsNextPage?: () => void;
154154
onVariantsPreviousPage?: () => void;
155155
variantsRangeLabel?: string | null;
156+
/** Absolute/filtered connection total — hide browse toolbar when 0 and not searching. */
157+
variantsTotalCount?: number | null;
156158
onGuardUnsavedAction?: (action: () => void) => void;
157159
selectedCount?: number;
158160
onDeleteSelected?: () => void;
@@ -178,6 +180,7 @@ export const ProductVariantsHeader = ({
178180
onVariantsNextPage,
179181
onVariantsPreviousPage,
180182
variantsRangeLabel,
183+
variantsTotalCount = null,
181184
onGuardUnsavedAction,
182185
selectedCount = 0,
183186
onDeleteSelected,
@@ -203,11 +206,16 @@ export const ProductVariantsHeader = ({
203206
})
204207
: intl.formatMessage(messages.title);
205208

206-
const showToolbar = Boolean(onVariantsSearchChange || variantsPageInfo);
209+
// Search filters totalCount — keep the bar while a query is active (even at 0 hits).
210+
// Hide when empty or still unknown so empty products don't flash a useless "0 of 0" bar.
211+
const hasActiveSearch = Boolean(variantsSearch.trim());
212+
const showToolbar =
213+
Boolean(onVariantsSearchChange || variantsPageInfo) &&
214+
(hasActiveSearch || (variantsTotalCount !== null && variantsTotalCount > 0));
207215
const runGuarded = onGuardUnsavedAction ?? ((action: () => void) => action());
208216

209217
return (
210-
<div className={styles.header}>
218+
<>
211219
<DatagridHeader title={headerTitle}>
212220
<DatagridHeader.ButtonFullScreen isOpen={isFullscreenOpen} onToggle={toggleFullscreen}>
213221
{isFullscreenOpen ? (
@@ -244,7 +252,7 @@ export const ProductVariantsHeader = ({
244252
>
245253
{onVariantsSearchChange ? (
246254
<Box __maxWidth="260px" width="100%">
247-
<Input
255+
<InputWithPlaceholder
248256
size="small"
249257
value={variantsSearch}
250258
onChange={event => {
@@ -325,6 +333,6 @@ export const ProductVariantsHeader = ({
325333
</Box>
326334
</Box>
327335
)}
328-
</div>
336+
</>
329337
);
330338
};

0 commit comments

Comments
 (0)