diff --git a/apps/user-ui/components/LocationTestWrapper.tsx b/apps/user-ui/components/LocationTestWrapper.tsx index f2ecf45..99ce8d8 100644 --- a/apps/user-ui/components/LocationTestWrapper.tsx +++ b/apps/user-ui/components/LocationTestWrapper.tsx @@ -148,6 +148,9 @@ const LocationTestWrapper: React.FC = ({ children }) => { { if (unit?.toLowerCase() === 'kg' && quantity < 1) { return { value: `${Math.round(quantity * 1000)} g`, display: `${Math.round(quantity * 1000)}g` }; @@ -225,7 +231,7 @@ const FloatingCartBar: React.FC = ({ )} setIsExpanded(false)} enableDismiss={true}> - + {/* Header */} @@ -365,7 +371,7 @@ const FloatingCartBar: React.FC = ({ {/* Fancy Footer */} - + Subtotal @@ -400,7 +406,7 @@ const FloatingCartBar: React.FC = ({ - + ); diff --git a/apps/user-ui/src/components/AddToCartDialog.tsx b/apps/user-ui/src/components/AddToCartDialog.tsx index eaa8a5e..745dcec 100644 --- a/apps/user-ui/src/components/AddToCartDialog.tsx +++ b/apps/user-ui/src/components/AddToCartDialog.tsx @@ -1,5 +1,5 @@ import React, { useState, useMemo, useEffect } from 'react'; -import { View, ScrollView } from 'react-native'; +import { View, ScrollView, Dimensions } from 'react-native'; import { useRouter } from 'expo-router'; import { tw, BottomDialog, MyText, MyTouchableOpacity, Quantifier } from 'common-ui'; import MaterialIcons from '@expo/vector-icons/MaterialIcons'; @@ -11,6 +11,12 @@ import { useGetEssentialConsts, useSlots } from '@/src/hooks/prominent-api-hooks import dayjs from 'dayjs'; import { SafeAreaView } from 'react-native-safe-area-context'; +// Height of the sheet's content box: the full 80% of the screen the dialog allows. +// Deliberate (not a max): the slot list is `flex-1`, so a definite height is what +// lets it take exactly the leftover space and scroll while the quantity row and the +// Cancel / Add to Cart row stay pinned at the bottom of the sheet. +const SHEET_HEIGHT = Dimensions.get('window').height * 0.8; + const formatTimeRange = (deliveryTime: string) => { const time = dayjs(deliveryTime); const endTime = time.add(1, 'hour'); @@ -155,8 +161,10 @@ export default function AddToCartDialog() { return ( - - + {/* Bottom sheet: only the bottom inset matters here — a top inset would just + add dead space between the handle and the header. */} + + @@ -171,7 +179,10 @@ export default function AddToCartDialog() { - + {/* The only scrolling region: this shrinks to whatever space is left in + the capped box above, so the quantity row and the Cancel / Add to + Cart row underneath it never move. */} + {availableSlots.map((slot: any) => ( ))} - - {!hasRegionSlots && !showFlashOption && ( - - - Not available in your region right now. - - - )} - - {showFlashOption && ( - { - setSelectedFlashDelivery(true); - setSelectedSlotId(null); - }} - activeOpacity={0.7} - > - - - 1 hr Delivery + {!hasRegionSlots && !showFlashOption && ( + + + Not available in your region right now. + - {selectedFlashDelivery ? ( - - ) : ( - - )} - - )} + )} + + {showFlashOption && ( + { + setSelectedFlashDelivery(true); + setSelectedSlotId(null); + }} + activeOpacity={0.7} + > + + + 1 hr Delivery + + {selectedFlashDelivery ? ( + + ) : ( + + )} + + )} + Quantity @@ -262,7 +273,7 @@ export default function AddToCartDialog() { - + void + /** + * Whether to mark the address the app would fall back to (the user's default) as + * the active one. The startup gate passes false: no region exists yet, so nothing + * is chosen, and a pre-marked card reads as "already done" instead of "tap this". + */ + highlightActiveAddress?: boolean } /** @@ -48,7 +54,12 @@ interface LocationFallbackFlowProps { * (which switches the browsing region + bound and clears the cart) or adds a * new one (coordinates required, via attach-location or the map). */ -const LocationFallbackFlow: React.FC = ({ onClose, notice, onOpenSettings }) => { +const LocationFallbackFlow: React.FC = ({ + onClose, + notice, + onOpenSettings, + highlightActiveAddress = true, +}) => { const queryClient = useQueryClient() const utils = trpc.useUtils() const auth = useAuthOptional() @@ -78,9 +89,11 @@ const LocationFallbackFlow: React.FC = ({ onClose, no // The address the app treats as active: an explicit pick (bar / cart / this // sheet) wins, otherwise the default. Same precedence as LocationBar, // CheckoutAddressSelector and CheckoutAddressDisplay, so the sheet cannot - // disagree with the bar it was opened from. - const activeAddressId = - selectedAddressId ?? addresses.find((address) => address.isDefault)?.id ?? null + // disagree with the bar it was opened from. Null in the startup gate, where + // nothing has been chosen yet — see highlightActiveAddress. + const activeAddressId = highlightActiveAddress + ? selectedAddressId ?? addresses.find((address) => address.isDefault)?.id ?? null + : null const activate = useCallback( async (regionId: number, boundId: number | null): Promise => { diff --git a/change-log.txt b/change-log.txt index 10fa6f8..f7a163d 100644 --- a/change-log.txt +++ b/change-log.txt @@ -5021,3 +5021,103 @@ user-ui CheckoutAddressSelector). The green "Default" badge and the "Set as default" link are unchanged - a default is not necessarily the active address. No store/API/backend changes; the sheet still selects via handleSelect. + +2026-10-16 20:48:35 user-ui: AddToCartDialog - slot list scrolls, Add to Cart row stays put. + + apps/user-ui/src/components/AddToCartDialog.tsx + ~ import Dimensions; new SHEET_MAX_HEIGHT = window height * 0.7. + ~ content box: `tw`p-6 max-h-[650px]`` -> `[tw`p-6`, { maxHeight: SHEET_MAX_HEIGHT }]`. + Why: BottomDialog wraps children in its OWN ScrollView and caps itself at 85% of the screen + (packages/ui/src/components/dialog.tsx:56-63,147). A fixed 650px box + its handle + safe-area + insets can exceed that cap on shorter devices, so the DIALOG scrolled and dragged the action + row off-screen. Capping at 0.7 * screen keeps the dialog's own scroll view inert on any + screen (0.7S + ~60 chrome <= 0.85S), so the footer cannot move. + ~ the slots ScrollView gets `tw`shrink`` (flexShrink 1, flexBasis auto) and now also holds the + "Not available in your region" notice and the 1 hr Delivery row, which were previously + siblings BELOW it. It is the only scrolling region, so it shrinks to the leftover space and + scrolls internally; the quantity row and the Cancel / Add to Cart row below it stay static. + Deliberately NOT `flex-1`: that is flexBasis 0%, which collapses to zero height inside an + auto-height (maxHeight-only) parent. Verified with the repo's own tw config: + max-h-[650px] -> {maxHeight:650}; shrink -> {flexShrink:1}; flex-1 -> {flexBasis:"0%"}. + ~ SafeAreaView edges={['bottom']}: a top inset inside a bottom sheet only added dead space + between the handle and the header (it also counted against the height budget above). + No other file changed. No store/API/backend changes. + +2026-10-16 21:20:10 user-ui: pin the action button for real - "Your Cart" dialog + AddToCartDialog. + + The "Go to cart" button is in the FLOATING CART dialog, not AddToCartDialog: + apps/user-ui/components/floating-cart-bar.tsx:227-404 wraps the whole sheet (header, free-delivery + progress, the items list AND the Subtotal / "Go to cart" footer) in ONE at line 228, + so the button scrolls away with the list. That is the button the user means, and the items list is + the "products list". Fixing it here; the earlier AddToCartDialog edit (right file per the original + request, but a different dialog) is made deterministic at the same time. + + apps/user-ui/components/floating-cart-bar.tsx + ~ line 228: `` -> ``; new CART_SHEET_HEIGHT = screenHeight * 0.72 (screenHeight already + exists at line 30). Closing tag at line 403 `` -> ``. + - With a DEFINITE sheet height the items ScrollView (already `flex-1`, line 267) gets exactly the + leftover space and is the only scrolling region; the header, the progress bar and the + Subtotal / Go to cart footer are static siblings. + - 0.72 * screen keeps the sheet + the dialog's handle inside BottomDialog's own 85%-of-screen + cap, so the dialog itself never scrolls (this is why a plain maxHeight is not enough: if the + sheet can outgrow that cap, the DIALOG scrolls and drags the footer with it). + + apps/user-ui/src/components/AddToCartDialog.tsx + ~ SHEET_MAX_HEIGHT (0.7 * screen, used as maxHeight) -> SHEET_HEIGHT used as a definite `height`, + and the slots ScrollView `tw`shrink`` -> `tw`flex-1``. + - Rationale: with only a maxHeight the parent's height is content-driven, so `flex-1` + (flexBasis 0%) would collapse the list; and relying on shrink alone depends on measure + semantics. A definite height makes the pinning deterministic: list = leftover, footer static. + - Trade-off: the sheet is now that tall even with one slot (blank space under the last row), + which is the price of a guaranteed-fixed action row. + No store/API/backend change. No other file changed. + +2026-10-16 21:42:15 user-ui: less dead space under the pinned action rows in both cart sheets. + + Feedback: "a lot of space between the go to cart button and the buttons below". Under the action row + there were three stacked paddings: the row's own bottom padding, the sheet's padding, AND + BottomDialog's own scroll-content paddingBottom (packages/ui/src/components/dialog.tsx:168 - + 40px iOS / 20px Android, inside the dialog, below our sheet). Only our own padding is ours to trim. + + apps/user-ui/components/floating-cart-bar.tsx ("Your Cart" footer with the Go to cart button) + ~ footer `p-6` -> `px-6 pt-6 pb-2` (24 -> 8 below the button). + apps/user-ui/src/components/AddToCartDialog.tsx (Add to Cart / Cancel row) + ~ action row `mt-4 pb-12` -> `mt-4 pb-2` (48 -> 8 below the row). + Not changed: the shared BottomDialog padding (20/40) - it is common-ui and affects every dialog. + If that remaining band still looks too big, the next step is a negative bottom margin on the sheet + (platform-coupled: -40 iOS / -20 Android), which I have deliberately not done unasked. + +2026-10-16 21:55:40 user-ui: both cart sheets take the full 80% of the screen height. + + "bottom dialog can take up 80% of screen height" - the original cart-dialog wrapper was + `maxHeight: height * 0.8` (floating-cart-bar.tsx), so 80% is the intended budget; I had made the + sheets 0.7/0.72 to fit the dialog's own 85% cap plus its handle/padding. Raising both to 0.8: + + apps/user-ui/components/floating-cart-bar.tsx + ~ CART_SHEET_HEIGHT = screenHeight * 0.72 -> screenHeight * 0.8. + apps/user-ui/src/components/AddToCartDialog.tsx + ~ SHEET_HEIGHT = Dimensions.get('window').height * 0.7 -> * 0.8. + Both comments updated: at 0.8 the sheet plus BottomDialog's handle (~25) and its own scroll-content + paddingBottom (dialog.tsx:168 - 40 iOS / 20 Android) can exceed the dialog's 85% cap by ~20px, which + lets the dialog scroll by that much (the pinned action row stays fully visible; the sheet simply + fills more of the screen as requested). More list room: ~660px vs ~580px on a 932pt screen. + No other file changed. + +2026-10-17 09:12:05 user-ui: the startup address chooser no longer pre-highlights the default. + + Feedback: on startup the chooser marks an address as the selected option, which is misleading - + nothing is chosen yet (no region), the user still has to tap one, so the brand card + check circle + reads as "already done". + + apps/user-ui/src/components/location/LocationFallbackFlow.tsx + + prop `highlightActiveAddress` (default true). When false, activeAddressId is null and no card + gets the brand tint / check circle; the green "Default" badge is untouched (it only says which + address is the default, not that it is chosen). + - the default fallback was the cause: activeAddressId = selectedAddressId ?? isDefault. In the + gate selectedAddressId is always null, so the default was highlighted. + apps/user-ui/components/LocationTestWrapper.tsx + ~ passes highlightActiveAddress={false} (the gate = no region resolved = nothing chosen). + - The sheet opened from the top region bar (AddressSwitcherSheet) keeps the default true, so it + still marks the address the app is actually using (and agrees with the bar). + No store/API changes. No test asserts the highlight (checked tests/).