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.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Fixed Currency Select default value passing
Damian Legawiec2c97f3d58177
diff --git a/packages/admin/e2e/promotions.spec.ts b/packages/admin/e2e/promotions.spec.tsindex 2fa96df05d..d78ce86d4a 100644--- a/packages/admin/e2e/promotions.spec.ts+++ b/packages/admin/e2e/promotions.spec.ts@@ -260,6 +260,36 @@ test.describe('promotions', () => {await submitCreate(page, name)})+ test('creates a promotion with a Currency rule defaulting to store currency', async ({+ page,+ }) => {+ const creds = await login(page)+ await gotoIndex(page, PROMOTIONS_PATH(creds.store_id), CTA)++ const name = `E2E Currency Promo ${Date.now()}`+ await startNewPromotion(page, creds.store_id, name)++ // The Currency rule has a single `:currency` preference with no schema+ // default. The picker should seed it from the store's default currency so+ // saving the editor (without touching the dropdown) round-trips a real+ // value — not an empty `preferences: {}` that the server quietly accepts+ // but the merchant never sees in the rule preview.+ await pickRule(page, /^currency$/i)+ await expect(page.getByRole('heading', { name: /^currency$/i })).toBeVisible({+ timeout: 5_000,+ })+ await saveEditor(page)++ // Row summary renders `Currency: USD` (humanized key + uppercased ISO).+ await expect(page.getByText(/currency:\s*USD/i).first()).toBeVisible({ timeout: 5_000 })++ await submitCreate(page, name)++ // Reopen the saved promotion's rule editor and confirm the currency+ // persisted server-side, not just in client memory.+ await expect(page.getByText(/currency:\s*USD/i).first()).toBeVisible({ timeout: 5_000 })+ })+test('creates a promotion with a Create Adjustment action', async ({ page }) => {const creds = await login(page)await gotoIndex(page, PROMOTIONS_PATH(creds.store_id), CTA)diff --git a/packages/admin/src/components/spree/currency-select.tsx b/packages/admin/src/components/spree/currency-select.tsxindex d90663dc4d..0562f0ecc2 100644--- a/packages/admin/src/components/spree/currency-select.tsx+++ b/packages/admin/src/components/spree/currency-select.tsx@@ -1,4 +1,4 @@-import { useMemo, useState } from 'react'+import { useEffect, useMemo, useState } from 'react'import {Select,SelectContent,@@ -66,6 +66,14 @@ export function CurrencySelect({const value = isControlled ? controlledValue : internalValueconst displayNameFor = useCurrencyDisplayName(defaultLocale)+ // Controlled callers that pass an empty value want the dropdown to *display*+ // the store default — but without a matching `onChange` they end up with a+ // mismatch between what the merchant sees ("USD") and what gets submitted+ // (""). Commit the fallback once so display and payload agree.+ useEffect(() => {+ if (isControlled && !controlledValue && defaultCurrency) onChange?.(defaultCurrency)+ }, [isControlled, controlledValue, defaultCurrency, onChange])+const handleChange = (next: string) => {if (!isControlled) setInternalValue(next)onChange?.(next)diff --git a/packages/admin/src/components/spree/resource-multi-autocomplete.tsx b/packages/admin/src/components/spree/resource-multi-autocomplete.tsxindex efb09ebe80..3d86e2b2e5 100644--- a/packages/admin/src/components/spree/resource-multi-autocomplete.tsx+++ b/packages/admin/src/components/spree/resource-multi-autocomplete.tsx@@ -191,6 +191,12 @@ export function ResourceMultiAutocomplete<T extends AutocompleteOption>({itemToStringLabel={(o) => getOptionLabel(o as T)}itemToStringValue={(o) => (o as T).id}isItemEqualToValue={(a, b) => (a as T).id === (b as T).id}+ // Filtering is server-side: `search(query)` already narrows the result+ // set. Disable Base UI's client filter so it doesn't hide rows whose+ // label doesn't substring-match the typed query (the typed query is+ // often shorter than the actual label — partial email, first name+ // only, etc.).+ filter={null}disabled={disabled}><ComboboxChips ref={anchorRef}>