Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Improve dashboard bulk action bar

Damian Legawiec85840dd7b1e2
diff --git a/docs/developer/upgrades/5.4-to-5.5.mdx b/docs/developer/upgrades/5.4-to-5.5.mdx
index 46921e1eef..8c7d022c55 100644
--- a/docs/developer/upgrades/5.4-to-5.5.mdx
+++ b/docs/developer/upgrades/5.4-to-5.5.mdx
@@ -43,17 +43,41 @@ bin/rails spree:media:migrate_master_images_to_product_media BATCH_SIZE=1000
### Run the Channels upgrade
-Spree 5.5 introduces Sales Channels. Database migration will create default channel automatically (for every store) and product publications (we're re-using the `spree_product_stores` table so no heavy database writes are needed for that), but orders need to be backfilled with `channel_id` to be associated with the correct channel.
+Spree 5.5 introduces [Sales Channels](/developer/core-concepts/channels) — a per-store distribution surface (online storefront, POS, marketplace integration, wholesale portal). Products are published to a channel via the new `spree_product_publications` join table, and orders are attributed to a channel via `spree_orders.channel_id`.
+
+The migrations add a `default` boolean on `spree_channels`, a `store_id` column on `spree_products`, and create the new `spree_product_publications` table — **but they do not seed default channels, attach existing products to a store, or backfill order channels**. That work is done by an idempotent rake task you must run after `db:migrate`:
```bash
bin/rake spree:channels:upgrade
```
-The task is idempotent — safe to re-run if it fails partway, and a no-op on stores/orders that have already been upgraded. It runs two sub-tasks in order:
+The task runs four sub-tasks in order:
+
+1. `spree:channels:create_defaults` — creates the default "Online Store" channel for every existing store (via `Store#ensure_default_channel`).
+2. `spree:upgrade:populate_publications` — for every product that doesn't yet have a `store_id`, picks a "home" store from the legacy `spree_products_stores` join (preferring the store flagged `default: true`, otherwise the earliest row), sets `spree_products.store_id`, and creates a `spree_product_publications` row on each attached store's default channel. Runs in a transaction per product so a partial failure leaves nothing half-applied.
+3. `spree:channels:backfill_order_channel_ids` — sets `spree_orders.channel_id` from the legacy `spree_orders.channel` string column. Unknown codes auto-create a new channel under that store. NULL/blank values map to the default channel.
+4. `spree:channels:backfill_product_publication_dates` — copies the deprecated `Product.available_on` and `Product.discontinue_on` columns into each publication's `published_at` / `unpublished_at` (only where the publication's date is currently NULL).
+
+The task is fully idempotent — safe to re-run if it fails partway, and a no-op on stores/products/orders that have already been upgraded.
+
+<Warning>
+ Until `spree:channels:upgrade` runs, every product has `store_id IS NULL` and is invisible to `Product.for_store(store)`. The admin product list, storefront catalog, and search indexer all return empty. Run the task immediately after `db:migrate`.
+</Warning>
+
+#### Multi-store catalogs
+
+If you have products attached to multiple stores via the legacy `spree_products_stores` join, the `populate_publications` task picks **one** "home" store per product and creates publications on every store's default channel. The `spree_products_stores` table is **kept** as legacy compat surface — the upcoming `spree_multi_store` extension restores the full `Product has_many :stores` association on top of it.
+
+For single-store deployments this is invisible; you can move on without touching `spree_products_stores` again.
+
+#### Behavioral changes
-Orders modified after the upgrade auto-set `channel_id` via the model's `before_validation` callback, so the backfill is only strictly required for orders that aren't touched again post-upgrade — but running it once at upgrade time avoids surprises later.
+- Newly-created products in **the dashboard SPA** are auto-published on the store's default channel (Shopify-style; the merchant can untick channels post-create via the Publishing card).
+- Newly-created products via the **Admin API** are NOT auto-published — the caller must supply `product_publications: [{ channel_id }]` on create or use `POST /api/v3/admin/channels/:id/add_products` afterwards.
+- `Product.available_on=` and `Product.discontinue_on=` setters emit deprecation warnings and now write to every per-channel publication's `published_at` / `unpublished_at`. Reading these attributes on a product prefers the current-channel publication's value over the legacy column.
+- `Spree::Channel#add_products(product_ids)` is idempotent and **preserves existing publication windows** when called without `published_at`/`unpublished_at` kwargs.
-The legacy `channel` string column is **kept** on `spree_orders` and ignored by ActiveRecord (`Spree::Order` declares it in `ignored_columns`). It will be dropped in a later Spree release once enough time has passed for everyone to have run the backfill — until then it's harmless DB ballast that lets the rake task be re-run if you need to.
+Orders modified after the upgrade auto-set `channel_id` via the model's `before_validation :ensure_channel_presence` callback, so `backfill_order_channel_ids` is only strictly required for orders that aren't touched again post-upgrade — but running it at upgrade time avoids surprises later. The legacy `channel` string column is **kept** on `spree_orders` and ignored by ActiveRecord (`Spree::Order` declares it in `ignored_columns`). It will be dropped in a later Spree release once everyone has had a chance to run the backfill.
### Schedule the Stock Reservations expiry job
diff --git a/packages/dashboard-core/package.json b/packages/dashboard-core/package.json
index b37c3dcf09..7fcfc87b2f 100644
--- a/packages/dashboard-core/package.json
+++ b/packages/dashboard-core/package.json
@@ -47,6 +47,8 @@
"@dnd-kit/sortable": "^10.0.0",
"@dnd-kit/utilities": "^3.2.2",
"@tailwindcss/vite": "^4.2.4",
+ "date-fns": "^4.1.0",
+ "date-fns-tz": "^3.2.0",
"lucide-react": "^1.14.0",
"spark-md5": "^3.0.2",
"zod": "^4.4.3"
diff --git a/packages/dashboard-core/src/components/bulk-action-bar.tsx b/packages/dashboard-core/src/components/bulk-action-bar.tsx
index 74581b777d..e98f63ffa8 100644
--- a/packages/dashboard-core/src/components/bulk-action-bar.tsx
+++ b/packages/dashboard-core/src/components/bulk-action-bar.tsx
@@ -1,8 +1,17 @@
-import { Button, useConfirm } from '@spree/dashboard-ui'
+import {
+ Button,
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuTrigger,
+ useConfirm,
+} from '@spree/dashboard-ui'
import type { QueryKey } from '@tanstack/react-query'
import { useQueryClient } from '@tanstack/react-query'
+import { MoreHorizontalIcon, XIcon } from 'lucide-react'
import type { ReactNode } from 'react'
-import { useEffect, useState } from 'react'
+import { useEffect, useLayoutEffect, useRef, useState } from 'react'
+import { createPortal } from 'react-dom'
import { useTranslation } from 'react-i18next'
import { toast } from 'sonner'
import { usePermissions } from '../providers/permission-provider'
@@ -79,13 +88,27 @@ interface BulkActionBarProps {
onClear: () => void
/** Called after a successful run to refresh the table / clear selection. */
onDone: () => void
+ /**
+ * When set, the bar centers itself horizontally inside this element's
+ * bounding rect on viewports wide enough to comfortably show it inside
+ * (>= +md+ breakpoint). On smaller viewports it falls back to centering
+ * against the visual viewport. Without this the bar always anchors to
+ * the viewport.
+ */
+ anchorRef?: React.RefObject<HTMLElement | null>
}
function interpolate(template: string, n: number) {
return template.replace(/\{n\}/g, String(n))
}
-export function BulkActionBar({ selectedIds, actions, onClear, onDone }: BulkActionBarProps) {
+export function BulkActionBar({
+ selectedIds,
+ actions,
+ onClear,
+ onDone,
+ anchorRef,
+}: BulkActionBarProps) {
const { t } = useTranslation()
const confirm = useConfirm()
const queryClient = useQueryClient()
@@ -158,47 +181,324 @@ export function BulkActionBar({ selectedIds, actions, onClear, onDone }: BulkAct
}
return (
+ <BulkActionBarLayout
+ count={count}
+ actions={visibleActions}
+ anchorRef={anchorRef}
+ onClear={onClear}
+ onClickAction={handleClick}
+ running={running}
+ pendingForm={pendingForm}
+ selectedIds={selectedIds}
+ onClosePendingForm={() => setPendingForm(null)}
+ onSubmitPendingForm={async (values) => {
+ const action = pendingForm
+ if (!action) return
+ setPendingForm(null)
+ await execute(action, values)
+ }}
+ />
+ )
+}
+
+interface BulkActionBarLayoutProps {
+ count: number
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ actions: BulkAction<any>[]
+ anchorRef?: React.RefObject<HTMLElement | null>
+ onClear: () => void
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ onClickAction: (action: BulkAction<any>) => void
+ running: boolean
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ pendingForm: BulkAction<any> | null
+ selectedIds: string[]
+ onClosePendingForm: () => void
+ onSubmitPendingForm: (values: unknown) => void
+}
+
+/**
+ * Splits the action list into "fits in the bar" + "overflow menu" based on
+ * the bar's actual rendered width.
+ *
+ * Why a separate component: hoisting the measurement effects + refs out of
+ * +BulkActionBar+ keeps the action-running logic readable and confines
+ * resize-observer setup to one place.
+ */
+function BulkActionBarLayout({
+ count,
+ actions,
+ anchorRef,
+ onClear,
+ onClickAction,
+ running,
+ pendingForm,
+ selectedIds,
+ onClosePendingForm,
+ onSubmitPendingForm,
+}: BulkActionBarLayoutProps) {
+ const { t } = useTranslation()
+
+ // The bar is centered (+w-fit+) so the parent doesn't constrain it; instead
+ // we cap against the viewport with a sensible margin.
+ const containerRef = useRef<HTMLDivElement | null>(null)
+ const measureRef = useRef<HTMLDivElement | null>(null)
+ // Width of the bar's leading section (clear button + label + divider).
+ const leadingRef = useRef<HTMLDivElement | null>(null)
+ const [visibleCount, setVisibleCount] = useState(actions.length)
+ // JS-computed position so it's immune to transformed ancestors.
+ const [barLeft, setBarLeft] = useState(0)
+ const [barTop, setBarTop] = useState(0)
+
+ // Max-width state so the bar never extends past its host region (the
+ // table card on desktop, the visual viewport on mobile).
+ const [maxWidth, setMaxWidth] = useState<number | null>(null)
+
+ // Reposition + remeasure on viewport resize, scroll, and font load.
+ useLayoutEffect(() => {
+ function reposition() {
+ const el = containerRef.current
+ if (!el) return
+ const width = el.offsetWidth
+ const height = el.offsetHeight
+ // visualViewport accounts for the mobile browser URL bar collapsing;
+ // falls back to window dimensions on browsers without the API.
+ const vv = window.visualViewport
+ const vpWidth = vv?.width ?? window.innerWidth
+ const vpHeight = vv?.height ?? window.innerHeight
+ const vpLeft = vv?.offsetLeft ?? 0
+ const vpTop = vv?.offsetTop ?? 0
+
+ // Pin to viewport bottom. The bar should always stay reachable —
+ // anchoring to the table card pinned it to the table's bottom, which
+ // sits off-screen when the table is taller than the viewport.
+ let left = vpLeft + Math.round((vpWidth - width) / 2)
+ // Cap width at viewport - 2rem on mobile.
+ let cap = vpWidth - 32
+ // If an anchor element is provided, clamp the horizontal center AND
+ // the max width to the anchor's bounding rect, so on desktop the bar
+ // reads as part of the table region rather than free-floating across
+ // the whole page.
+ const anchor = anchorRef?.current
+ if (anchor && vpWidth >= 768) {
+ const rect = anchor.getBoundingClientRect()
+ left = rect.left + Math.round((rect.width - width) / 2)
+ cap = Math.round(rect.width * 0.9) // 90% of the table card width
+ }
+ setBarLeft(left)
+ setBarTop(vpTop + vpHeight - height - 16) // 16px from bottom
+ setMaxWidth(cap)
+ }
+ reposition()
+ window.addEventListener('resize', reposition)
+ window.addEventListener('scroll', reposition, true)
+ window.visualViewport?.addEventListener('resize', reposition)
+ window.visualViewport?.addEventListener('scroll', reposition)
+ // Track the anchor's own size/position changes (sidebar collapse,
+ // pagination footer height swaps, etc.).
+ let ro: ResizeObserver | undefined
+ if (anchorRef?.current) {
+ ro = new ResizeObserver(reposition)
+ ro.observe(anchorRef.current)
+ }
+ return () => {
+ window.removeEventListener('resize', reposition)
+ window.removeEventListener('scroll', reposition, true)
+ window.visualViewport?.removeEventListener('resize', reposition)
+ window.visualViewport?.removeEventListener('scroll', reposition)
+ ro?.disconnect()
+ }
+ // Re-run when the anchor element resolves (refs are null on first render
+ // and populated on the next commit). The +ResizeObserver+ + window
+ // listeners re-attach to whatever anchor the consumer passed.
+ }, [anchorRef?.current])
+
+ // Measure once on mount + whenever the container or action set changes.
+ // +useLayoutEffect+ so the user never sees a flash of overflowing actions.
+ useLayoutEffect(() => {
+ function recompute() {
+ const measure = measureRef.current
+ const leading = leadingRef.current
+ if (!measure || !leading) return
+
+ // Compute available action-area width against the same cap that the
+ // bar's +max-width+ uses (table card width on desktop, viewport on
+ // mobile) so the overflow count matches what the user will see.
+ const anchor = anchorRef?.current
+ const vpWidth = document.documentElement.clientWidth
+ const cap =
+ anchor && vpWidth >= 768
+ ? Math.round(anchor.getBoundingClientRect().width * 0.9)
+ : vpWidth - 32
+ // 16px for the bar's own +p-1+ + border + subpixel safety pad.
+ const available = cap - 16 - leading.offsetWidth
+ // +⋯+ button (icon-sm = 28px) + gap on each side + safety margin.
+ // 64px keeps the dropdown comfortably visible on narrow viewports
+ // and gives the menu room to position without spilling off-screen.
+ const moreWidth = 64
+ const children = Array.from(measure.children) as HTMLElement[]
+ const widths = children.map((el) => el.offsetWidth)
+
+ let used = 0
+ let n = 0
+ for (let i = 0; i < widths.length; i++) {
+ // If this is the last action and the rest fit without +⋯+, take all.
+ const reserve = i === widths.length - 1 ? 0 : moreWidth
+ if (used + widths[i] + reserve <= available) {
+ used += widths[i]
+ n = i + 1
+ } else {
+ break
+ }
+ }
+ setVisibleCount(n)
+ }
+
+ recompute()
+ const ro = new ResizeObserver(recompute)
+ if (containerRef.current) ro.observe(containerRef.current)
+ if (anchorRef?.current) ro.observe(anchorRef.current)
+ window.addEventListener('resize', recompute)
+ return () => {
+ ro.disconnect()
+ window.removeEventListener('resize', recompute)
+ }
+ // Re-run only when the anchor element resolves (refs are null on first
+ // render and populated on commit). Changes to +actions+ don't need an
+ // explicit dep — the +ResizeObserver+ on the container fires when
+ // children render/unrender, which re-triggers +recompute+.
+ }, [anchorRef?.current])
+
+ const visible = actions.slice(0, visibleCount)
+ const overflow = actions.slice(visibleCount)
+
+ // JS-driven positioning: +position: fixed+ silently re-anchors to a
+ // transformed/contained ancestor (sidebar wrapper, Card, etc.) on this
+ // app. Portaling to +document.body+ should sidestep that, but in
+ // practice the bar still landed at the table's bottom on mobile. So we
+ // set explicit +top/left+ in pixels from +window+ measurements every
+ // frame the viewport changes. No CSS positioning, no ambiguity.
+ const bar = (
<>
- {/* Sticky bar above the table body. Stays at the bottom of the viewport
- when the table is long, so the action set is always reachable. */}
- <div className="sticky bottom-4 z-20 mx-4 my-3 flex items-center gap-2 rounded-lg border bg-popover px-3 py-2 shadow-md">
- <span className="text-sm font-medium">
- {t('admin.components.bulk_action_bar.selected', { count })}
- </span>
- <Button
- type="button"
- variant="ghost"
- size="sm"
- onClick={onClear}
- className="text-muted-foreground"
+ <div
+ ref={containerRef}
+ style={{
+ position: 'fixed',
+ left: `${barLeft}px`,
+ top: `${barTop}px`,
+ maxWidth: maxWidth != null ? `${maxWidth}px` : 'calc(100vw - 2rem)',
+ }}
+ className="z-50 flex w-fit items-center gap-0.5 rounded-xl border bg-popover p-1 shadow-md"
+ >
+ <div ref={leadingRef} className="flex items-center gap-0.5">
+ <Button
+ type="button"
+ variant="ghost"
+ size="icon-sm"
+ onClick={onClear}
+ aria-label={t('admin.actions.clear')}
+ className="text-muted-foreground"
+ >
+ <XIcon className="size-4" />
+ </Button>
+ <span className="whitespace-nowrap px-1.5 text-sm">
+ {t('admin.components.bulk_action_bar.selected', { count })}
+ </span>
+ <div className="mx-1 h-5 w-px bg-border" aria-hidden />
+ </div>
+
+ {visible.map((action) => (
+ <BulkActionButton
+ key={action.key}
+ action={action}
+ disabled={running}
+ onClick={() => onClickAction(action)}
+ />
+ ))}
+
+ {overflow.length > 0 && (
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <Button
+ type="button"
+ variant="ghost"
+ size="icon-sm"
+ aria-label={t('admin.actions.more_actions')}
+ >
+ <MoreHorizontalIcon className="size-4" />
+ </Button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end">
+ {overflow.map((action) => (
+ <DropdownMenuItem
+ key={action.key}
+ onClick={() => onClickAction(action)}
+ disabled={running}
+ className="py-1.5"
+ >
+ {action.icon}
+ {action.label}
+ </DropdownMenuItem>
+ ))}
+ </DropdownMenuContent>
+ </DropdownMenu>
+ )}
+
+ {/* Off-screen measuring layer: rendered with the same button styling
+ as the visible row so +offsetWidth+ reflects the real width.
+ +aria-hidden+ + +inert+-equivalent (no pointer events, no focus). */}
+ <div
+ ref={measureRef}
+ aria-hidden
+ className="pointer-events-none invisible absolute left-0 top-0 flex items-center gap-0.5"
>
- {t('admin.actions.clear')}
- </Button>
- <div className="ml-auto flex flex-wrap items-center gap-1">
- {visibleActions.map((action) => (
- <Button
+ {actions.map((action) => (
+ <BulkActionButton
key={action.key}
- type="button"
- variant="outline"
- size="sm"
- onClick={() => handleClick(action)}
- disabled={running}
- >
- {action.icon}
- {action.label}
- </Button>
+ action={action}
+ disabled
+ onClick={() => undefined}
+ tabIndex={-1}
+ />
))}
</div>
</div>
{pendingForm?.form?.({
ids: selectedIds,
- onCancel: () => setPendingForm(null),
- onSubmit: async (values) => {
- const action = pendingForm
- setPendingForm(null)
- await execute(action, values)
- },
+ onCancel: onClosePendingForm,
+ onSubmit: onSubmitPendingForm,
})}
</>
)
+
+ if (typeof document === 'undefined') return bar
+ return createPortal(bar, document.body)
+}
+
+function BulkActionButton({
+ action,
+ disabled,
+ onClick,
+ tabIndex,
+}: {
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ action: BulkAction<any>
+ disabled: boolean
+ onClick: () => void
+ tabIndex?: number
+}) {
+ return (
+ <Button
+ type="button"
+ variant="ghost"
+ size="sm"
+ onClick={onClick}
+ disabled={disabled}
+ tabIndex={tabIndex}
+ className="gap-1.5 whitespace-nowrap px-2"
+ >
+ {action.icon}
+ {action.label}
+ </Button>
+ )
}
diff --git a/packages/dashboard-core/src/components/resource-multi-autocomplete.tsx b/packages/dashboard-core/src/components/resource-multi-autocomplete.tsx
index 7a53d04582..8df3aa8dcc 100644
--- a/packages/dashboard-core/src/components/resource-multi-autocomplete.tsx
+++ b/packages/dashboard-core/src/components/resource-multi-autocomplete.tsx
@@ -35,6 +35,15 @@ export interface ResourceMultiAutocompleteProps<T extends AutocompleteOption>
/** Stable cache key for this picker instance — e.g. `'rule-products'`. */
queryKey: string
+
+ /**
+ * Records to seed the dropdown with — shown before the user types
+ * anything. Use when the resource is small enough that the caller
+ * already holds the full list in a cached query (channels, markets,
+ * categories) and the "type to search" UX is overkill. Merges with
+ * `search` results once the user starts typing.
+ */
+ initialItems?: T[]
}
/**
@@ -56,6 +65,7 @@ export function ResourceMultiAutocomplete<T extends AutocompleteOption>({
search,
hydrate,
queryKey,
+ initialItems,
getOptionLabel,
placeholder,
emptyText,
@@ -114,12 +124,18 @@ export function ResourceMultiAutocomplete<T extends AutocompleteOption>({
if (searchData?.data?.length) cacheItems(searchData.data)
}, [searchData, cacheItems])
- // Dropdown items — search results, then any selected IDs not in
- // results so the user can deselect chips via the dropdown.
+ useEffect(() => {
+ if (initialItems?.length) cacheItems(initialItems)
+ }, [initialItems, cacheItems])
+
+ // Dropdown items — search results (or +initialItems+ when nothing has
+ // been typed yet), then any selected IDs not in results so the user
+ // can deselect chips via the dropdown.
const items = useMemo<T[]>(() => {
const seen = new Set<string>()
const list: T[] = []
- for (const item of searchData?.data ?? []) {
+ const base = searchData?.data ?? (trimmedInput.length === 0 ? initialItems : null) ?? []
+ for (const item of base) {
if (seen.has(item.id)) continue
seen.add(item.id)
list.push(item)
@@ -133,7 +149,7 @@ export function ResourceMultiAutocomplete<T extends AutocompleteOption>({
}
}
return list
- }, [searchData, value, cache])
+ }, [searchData, value, cache, initialItems, trimmedInput])
// Stub-fallback so chips show their ID until hydration lands.
const selectedOptions = useMemo<T[]>(
diff --git a/packages/dashboard-core/src/components/resource-table.tsx b/packages/dashboard-core/src/components/resource-table.tsx
index 5e02aa55d5..4f4892fa5e 100644
--- a/packages/dashboard-core/src/components/resource-table.tsx
+++ b/packages/dashboard-core/src/components/resource-table.tsx
@@ -45,6 +45,7 @@ import {
useDeferredValue,
useEffect,
useMemo,
+ useRef,
useState,
} from 'react'
import { useTranslation } from 'react-i18next'
@@ -198,6 +199,9 @@ export function ResourceTable<T extends Record<string, any>>({
const selectionEnabled = !!bulkActions?.length && !reorder
const rowActionsEnabled = !!rowActions
const [selectedIds, setSelectedIds] = useState<Set<string>>(() => new Set())
+ // Used by +BulkActionBar+ to anchor itself within the table card on
+ // desktop (instead of free-floating at the viewport bottom).
+ const cardRef = useRef<HTMLDivElement | null>(null)
const {
page,
@@ -392,7 +396,7 @@ export function ResourceTable<T extends Record<string, any>>({
: actions
return (
- <Card className="rounded-xl">
+ <Card ref={cardRef} className="rounded-xl">
<TableToolbar
columns={displayableColumns}
visibleColumns={visibleColumnKeys}
@@ -566,6 +570,7 @@ export function ResourceTable<T extends Record<string, any>>({
<BulkActionBar
selectedIds={Array.from(selectedIds)}
actions={bulkActions!}
+ anchorRef={cardRef}
onClear={() => setSelectedIds(new Set())}
onDone={() => {
setSelectedIds(new Set())
diff --git a/packages/dashboard-ui/src/spree/data-grid/fill-handle.tsx b/packages/dashboard-ui/src/spree/data-grid/fill-handle.tsx
index 56ea8d0784..dc1ca1c94d 100644
--- a/packages/dashboard-ui/src/spree/data-grid/fill-handle.tsx
+++ b/packages/dashboard-ui/src/spree/data-grid/fill-handle.tsx
@@ -90,7 +90,7 @@ export function FillHandle({ gridRef }: { gridRef: React.RefObject<HTMLElement |
let hit: CellCoords | null = null
for (const reg of cells.values()) {
const el = reg.getElement?.()
- if (el && el.contains(target as Node)) {
+ if (el?.contains(target as Node)) {
hit = reg.coords
break
}
diff --git a/packages/dashboard-ui/src/styles.css b/packages/dashboard-ui/src/styles.css
index 35bbbb50f6..0414ddfab0 100644
--- a/packages/dashboard-ui/src/styles.css
+++ b/packages/dashboard-ui/src/styles.css
@@ -255,6 +255,13 @@
body {
@apply bg-background text-foreground text-base;
line-height: 1.5;
+ /* Lock body to the visible viewport width. Without this an overflowing
+ * descendant (a wide table on mobile) lets the body widen — and
+ * +position: fixed+ children center against +body+, not the viewport,
+ * landing off-screen. The descendant stays scrollable inside its own
+ * overflow container. */
+ overflow-x: hidden;
+ max-width: 100vw;
}
/* Headings — semibold (600) like Rails admin */