Skip to content

Commit 18b5714

Browse files
committed
fix(dashboard): Preserve selector tab state on draft order customer/address selectors
Reset the customer selector tab to 'existing' when a customer is selected or created (programmatic close does not trigger onOpenChange), and preserve an explicitly chosen 'new' tab in the address selector while the address query transitions from loading to loaded. Relates to vendurehq#4810
1 parent cfa605f commit 18b5714

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

packages/dashboard/src/app/routes/_authenticated/_orders/components/customer-address-selector.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ export function CustomerAddressSelector({
5151
// Existing addresses are only selectable when a customer with saved addresses is present.
5252
// Otherwise, the admin can only enter a new ad-hoc address (matching the Angular admin-ui).
5353
const canSelectExisting = !!customerId && addresses.length > 0;
54-
const effectiveTab = canSelectExisting ? activeTab : 'new';
54+
// Only force the "new" tab once we know the customer has no selectable addresses. While the
55+
// query is still loading we honour the explicitly chosen tab so the selection doesn't jump
56+
// when the addresses transition from loading to loaded.
57+
const effectiveTab = canSelectExisting || (!!customerId && isLoading) ? activeTab : 'new';
5558

5659
return (
5760
<Popover

packages/dashboard/src/lib/components/shared/customer-selector.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ export function CustomerSelector(props: CustomerSelectorProps) {
261261
onSelect={customer => {
262262
props.onSelect(customer);
263263
setOpen(false);
264+
setActiveTab('existing');
264265
}}
265266
/>
266267
</div>
@@ -271,6 +272,7 @@ export function CustomerSelector(props: CustomerSelectorProps) {
271272
onSubmit={input => {
272273
props.onCreateNew?.(input);
273274
setOpen(false);
275+
setActiveTab('existing');
274276
}}
275277
/>
276278
</div>

0 commit comments

Comments
 (0)