From 7e2cca0e343509c8d35a3bf0b55427c74cda5ff8 Mon Sep 17 00:00:00 2001 From: shafi54 <108669266+shafi-aviz@users.noreply.github.com> Date: Wed, 21 Oct 2026 19:10:38 +0530 Subject: [PATCH] enh --- .../(drawer)/(tabs)/me/addresses/index.tsx | 24 ++++++- .../app/(drawer)/(tabs)/me/my-orders/[id].tsx | 8 +-- apps/user-ui/components/ComplaintForm.tsx | 8 +-- apps/user-ui/components/OrderMenu.tsx | 33 +++++---- apps/user-ui/src/components/AddressForm.tsx | 36 ++++++---- .../tests/components/address-form.test.tsx | 30 ++------ apps/web-ui/src/components/AddressForm.tsx | 7 -- change-log.txt | 40 +++++++++++ packages/ui/src/components/dialog.tsx | 69 ++++++++++--------- 9 files changed, 153 insertions(+), 102 deletions(-) diff --git a/apps/user-ui/app/(drawer)/(tabs)/me/addresses/index.tsx b/apps/user-ui/app/(drawer)/(tabs)/me/addresses/index.tsx index 10d4985..4bf4fa0 100644 --- a/apps/user-ui/app/(drawer)/(tabs)/me/addresses/index.tsx +++ b/apps/user-ui/app/(drawer)/(tabs)/me/addresses/index.tsx @@ -1,6 +1,6 @@ -import React, { useState } from 'react'; +import React, { useEffect, useState } from 'react'; import type { UserAddress } from '@packages/shared' -import { View, Alert, Dimensions } from 'react-native'; +import { View, Alert, Dimensions, Keyboard } from 'react-native'; import { useRouter } from 'expo-router'; import { AppContainer, MyText, tw, useMarkDataFetchers, MyFlatList, MyTouchableOpacity, BottomDialog, RawBottomDialog } from 'common-ui'; import { trpc } from '@/src/trpc-client'; @@ -91,6 +91,23 @@ export default function Addresses() { const [editingAddress, setEditingAddress] = useState
(null); // Reason a delete was refused (only address / still the default / open order) — shown in a bottom sheet. const [deleteError, setDeleteError] = useState(null); + // Size the address sheet to the form when the keyboard is closed; keep the + // full 85% while editing so the scrollable area stays usable. + const [formContentHeight, setFormContentHeight] = useState(null); + const [keyboardVisible, setKeyboardVisible] = useState(false); + useEffect(() => { + const show = Keyboard.addListener('keyboardDidShow', () => setKeyboardVisible(true)); + const hide = Keyboard.addListener('keyboardDidHide', () => setKeyboardVisible(false)); + return () => { + show.remove(); + hide.remove(); + }; + }, []); + const windowHeight = Dimensions.get('window').height; + const maxSheetHeight = windowHeight * 0.85; + const sheetHeight = keyboardVisible + ? maxSheetHeight + : Math.min(maxSheetHeight, formContentHeight ?? maxSheetHeight); const { data, isLoading, error, refetch } = trpc.user.address.getUserAddresses.useQuery(); @@ -268,8 +285,9 @@ export default function Addresses() { /> setModalVisible(false)}> - + setCancelDialogOpen(false)}> - - - + + Cancel Order setCancelDialogOpen(false)}> @@ -428,7 +427,6 @@ export default function OrderDetails() { )} - {/* Raise Complaint Dialog */} diff --git a/apps/user-ui/components/ComplaintForm.tsx b/apps/user-ui/components/ComplaintForm.tsx index 538d482..6c1ed1d 100644 --- a/apps/user-ui/components/ComplaintForm.tsx +++ b/apps/user-ui/components/ComplaintForm.tsx @@ -1,5 +1,5 @@ import React, { useState } from 'react'; -import { View, TextInput, ActivityIndicator, KeyboardAvoidingView, Platform, Alert } from 'react-native'; +import { View, TextInput, ActivityIndicator, Alert } from 'react-native'; import { MaterialIcons } from '@expo/vector-icons' import { MyText, ImageUploaderNeo, tw, MyTouchableOpacity, type ImageUploaderNeoItem, type ImageUploaderNeoPayload } from 'common-ui' import { trpc } from '@/src/trpc-client' @@ -76,9 +76,8 @@ export default function ComplaintForm({ open, onClose, orderId }: ComplaintFormP if (!open) return null; return ( - - - + + Raise Complaint @@ -118,6 +117,5 @@ export default function ComplaintForm({ open, onClose, orderId }: ComplaintFormP )} - ); } diff --git a/apps/user-ui/components/OrderMenu.tsx b/apps/user-ui/components/OrderMenu.tsx index 23366d6..7233497 100644 --- a/apps/user-ui/components/OrderMenu.tsx +++ b/apps/user-ui/components/OrderMenu.tsx @@ -1,5 +1,5 @@ import React, { useState } from 'react'; -import { View, Alert, KeyboardAvoidingView, Platform, TextInput, ActivityIndicator } from 'react-native'; +import { View, Alert, TextInput, ActivityIndicator } from 'react-native'; import { MaterialIcons, Ionicons } from '@expo/vector-icons'; import { tw, MyText, MyTouchableOpacity, BottomDialog } from 'common-ui'; import { trpc } from '@/src/trpc-client'; @@ -80,7 +80,8 @@ const OrderMenu: React.FC = ({ orderId, postActionHandler }) => {/* Menu Dialog */} - setOpen(false)}> + {open && ( + setOpen(false)}> {/* Handle */} @@ -132,7 +133,10 @@ const OrderMenu: React.FC = ({ orderId, postActionHandler }) => setComplaintDialogOpen(true)} + onPress={() => { + setOpen(false); + setComplaintDialogOpen(true); + }} > @@ -164,11 +168,12 @@ const OrderMenu: React.FC = ({ orderId, postActionHandler }) => + )} {/* Edit Notes Dialog */} - setEditNotesDialogOpen(false)}> - - + {editNotesDialogOpen && ( + setEditNotesDialogOpen(false)}> + Edit Instructions setEditNotesDialogOpen(false)}> @@ -201,13 +206,13 @@ const OrderMenu: React.FC = ({ orderId, postActionHandler }) => )} - + )} {/* Cancel Order Dialog */} - setCancelDialogOpen(false)}> - - + {cancelDialogOpen && ( + setCancelDialogOpen(false)}> + Cancel Order setCancelDialogOpen(false)}> @@ -247,17 +252,19 @@ const OrderMenu: React.FC = ({ orderId, postActionHandler }) => )} - + )} {/* Raise Complaint Dialog */} - + {complaintDialogOpen && ( + + )} ); }; diff --git a/apps/user-ui/src/components/AddressForm.tsx b/apps/user-ui/src/components/AddressForm.tsx index aeb2c0c..a4326c8 100644 --- a/apps/user-ui/src/components/AddressForm.tsx +++ b/apps/user-ui/src/components/AddressForm.tsx @@ -16,12 +16,16 @@ type ResolvedRegion = { regionId: number; boundId: number | null }; // Where the delivery coordinates came from, so the heading can say so. type LocationSource = 'device' | 'map'; -const AddressForm: React.FC = ({ +const AddressForm: React.FC void; +}> = ({ onSuccess, initialValues, isEdit = false, draftMode = false, onResolvedRegion, + onContentHeightChange, }) => { const { regionId: browsingRegionId, boundId: browsingBoundId } = useRegion(); const deviceCoords = useLocationStore((state) => state.coords); @@ -42,6 +46,17 @@ const AddressForm: React.FC = ({ const [locationSource, setLocationSource] = useState( initialValues?.latitude != null && initialValues?.longitude != null ? 'device' : null ); + // Bottom sheets size to content when idle, but need the extra scroll room only + // while the keyboard is up. + const [keyboardVisible, setKeyboardVisible] = useState(false); + useEffect(() => { + const show = Keyboard.addListener('keyboardDidShow', () => setKeyboardVisible(true)); + const hide = Keyboard.addListener('keyboardDidHide', () => setKeyboardVisible(false)); + return () => { + show.remove(); + hide.remove(); + }; + }, []); const utils = trpc.useUtils(); @@ -74,8 +89,8 @@ const AddressForm: React.FC = ({ setMapRegionPickerOpen(false); }, []); - // "Select in Map" (City selector and region picker): no region named, so open - // the map straight away on the first region's bound. + // "Select in Map" in the region picker: no region named, so open the map + // straight away on the first region's bound. const openMapForFirstRegion = useCallback(() => { const firstRegion = regions[0] ?? null; setMapRegionPickerOpen(false); @@ -215,7 +230,11 @@ const AddressForm: React.FC = ({ > onContentHeightChange?.(height)} keyboardShouldPersistTaps="handled" showsVerticalScrollIndicator={false} > @@ -337,15 +356,8 @@ const AddressForm: React.FC = ({ label="Select Town" placeholder="Select town" value={resolvedRegion?.regionId ?? ''} - options={[ - ...regions.map((region) => ({ label: region.name, value: region.id })), - { label: 'Select in Map', value: 'map' }, - ]} + options={regions.map((region) => ({ label: region.name, value: region.id }))} onValueChange={(value) => { - if (value === 'map') { - openMapForFirstRegion(); - return; - } void handleCityChange(Number(value)); }} /> diff --git a/apps/user-ui/tests/components/address-form.test.tsx b/apps/user-ui/tests/components/address-form.test.tsx index 2886258..9a5d21e 100644 --- a/apps/user-ui/tests/components/address-form.test.tsx +++ b/apps/user-ui/tests/components/address-form.test.tsx @@ -103,12 +103,6 @@ function openMapViaChooser(screen: any, regionId = 1) { fireEvent.press(screen.getByTestId(`address-map-region-${regionId}`)) } -/** Open the map through the City picker's "Select in Map" option. */ -function openMapViaCity(screen: any) { - fireEvent.press(screen.getByTestId('address-city')) - fireEvent.press(screen.getByTestId('address-city-option-map')) -} - function sendMapMessage(screen: any, payload: string) { fireEvent(screen.getByTestId('webview'), 'message', { nativeEvent: { data: payload } }) } @@ -207,16 +201,17 @@ describe('AddressForm', () => { expect(getByText('Attach a location to add address')).toBeTruthy() }) - it('ADDRF-10: opening the city picker lists the regions, "Select in Map" and no empty message', async () => { + it('ADDRF-10: opening the city picker lists only the regions', async () => { denyLocation() - const { getByTestId, getByText, queryByText } = renderForm() + const { getByTestId, queryByTestId, queryByText } = renderForm() await flush() fireEvent.press(getByTestId('address-city')) expect(getByTestId('address-city-option-1')).toBeTruthy() expect(getByTestId('address-city-option-2')).toBeTruthy() - expect(getByText('Select in Map')).toBeTruthy() + expect(queryByTestId('address-city-option-map')).toBeNull() + expect(queryByText('Select in Map')).toBeNull() expect(queryByText('No towns available')).toBeNull() }) @@ -278,18 +273,6 @@ describe('AddressForm', () => { ) }) - it('ADDRF-14: "Select in Map" from the city picker opens the map at the first region centre', async () => { - denyLocation() - setProcedure('common.listRegions', { data: [REGION_1_CENTER, REGION_2_CENTER] }) - const { getByTestId } = renderForm() - await flush() - - openMapViaCity({ getByTestId } as any) - - const webview = getByTestId('webview') - expect(webview.props.source.uri).toBe(`${MAP_BASE}?lat=11&lng=22`) - }) - it('ADDRF-15: the location chooser opens the region picker and marks the current region', async () => { denyLocation() seedRegion(REGION_1, 7) @@ -668,7 +651,7 @@ describe('AddressForm', () => { const { getByTestId } = renderForm() await flush() - openMapViaCity({ getByTestId } as any) + openMapViaChooser({ getByTestId } as any) const uri = getByTestId('webview').props.source.uri expect(uri).toContain('?lat=11') @@ -680,7 +663,8 @@ describe('AddressForm', () => { const { getByTestId } = renderForm() await flush() - openMapViaCity({ getByTestId } as any) + fireEvent.press(getByTestId('address-attach-location')) + fireEvent.press(getByTestId('address-map-region-select-in-map')) expect(getByTestId('webview').props.source.uri).toBe(MAP_BASE) }) diff --git a/apps/web-ui/src/components/AddressForm.tsx b/apps/web-ui/src/components/AddressForm.tsx index 5a67db4..30bd4ae 100644 --- a/apps/web-ui/src/components/AddressForm.tsx +++ b/apps/web-ui/src/components/AddressForm.tsx @@ -304,12 +304,6 @@ export function AddressForm({ onSuccess, initialValues, isEdit = false, onResolv data-testid="address-city" value={resolvedRegion?.regionId ?? ''} onChange={(e) => { - if (e.target.value === 'map') { - const firstRegion = regions[0] ?? null - setMapCenter(firstRegion?.center ?? null) - setMapOpen(true) - return - } void handleCityChange(Number(e.target.value)) }} className="w-full rounded-lg border border-gray-200 bg-gray-50 p-3 text-base outline-none" @@ -320,7 +314,6 @@ export function AddressForm({ onSuccess, initialValues, isEdit = false, onResolv {region.name} ))} -
diff --git a/change-log.txt b/change-log.txt index 875c6ff..a451d8e 100644 --- a/change-log.txt +++ b/change-log.txt @@ -8595,3 +8595,43 @@ around a wait for either screen, then the dashboard is required. and then dropped to the login screen, skipping the conditional login. Fixed by attempting the login subflow on both sides of a wait for either screen. Left in place for inspection: slot 2118 and staff devslothook (id 10). + +[2026-10-21 17:59:28 IST] apps/user-ui/src/components/AddressForm.tsx: increase the ScrollView bottom +content padding (pb-10 -> pb-24) so the form can scroll far enough for the +"Add Address"/"Update Address" submit button and its inline error to clear the +iOS keyboard/home indicator inside the My Addresses RawBottomDialog. + Typecheck: user-ui clean. Not mirrored to web-ui: the web Add Address form is + not inside this native keyboard-driven RawBottomDialog (no soft keyboard). + +[2026-10-21 18:01:40 IST] apps/user-ui address sheet: stop the fixed 85% empty height. +- AddressForm: track keyboard visibility, paddingBottom 40 (closed) / 96 (open), + and report its natural content height via onContentHeightChange. +- My Addresses: sheet height = content height when the keyboard is closed (capped + at 85%), 85% while the keyboard is open so editing still has room. + Typecheck: user-ui clean. Web counterpart not applicable (no native keyboard / + this sheet). + +[2026-10-21 18:03:21 IST] Hide "Select in Map" from the City dropdown (user-ui + web-ui), +keeping the separate map picker/location controls. Update ADDRF-10 and drop the +city-picker map test ADDRF-14 (the chooser map test ADDRF-17 still covers it). +Run: user-ui typecheck clean; address-form tests 36/36 (ADDRF-14 removed, +ADDRF-10 updated, ADDRF-36/37 now use the chooser map). web-ui typecheck clean. + +[2026-10-21 18:38:57 IST] iOS BottomDialog keyboard lift. +- packages/ui/src/components/dialog.tsx: move the KeyboardAvoidingView outside the + absolute dialog (backdrop absolutely fills, KAV flex-end anchors the sheet) and + size the sheet to content up to 85%, so padding behavior actually lifts it. +- Remove nested KeyboardAvoidingView wrappers from OrderMenu (edit notes, cancel), + ComplaintForm, and the My Orders cancel dialog; the shared BottomDialog owns it. + Verified: user-ui typecheck clean; order-menu 10/10; address-form + cart 146/146. + Web-ui not affected (no shared BottomDialog). + +[2026-10-21 18:48:27 IST] iOS My Orders: order menu opens only once. +- BottomDialog: move the backdrop inside the KeyboardAvoidingView (drop + pointerEvents=box-none) so outside taps reliably reach the backdrop and no + invisible touch layer is left. +- OrderMenu: mount each BottomDialog only while its open flag is true, so closed + dialogs cannot leave a hidden native Modal over the order card. +- Also: raise-complaint now closes the menu (instead of stacking a second Modal on + top), and BottomDialog backdrop sits inside the KeyboardAvoidingView so outside + taps reliably dismiss. Verified: user-ui typecheck clean; order-menu 10/10. diff --git a/packages/ui/src/components/dialog.tsx b/packages/ui/src/components/dialog.tsx index 37adbbe..92213af 100755 --- a/packages/ui/src/components/dialog.tsx +++ b/packages/ui/src/components/dialog.tsx @@ -34,35 +34,36 @@ export const BottomDialog: React.FC = ({ open, onClose, children, e animationType="none" onRequestClose={enableDismiss ? onClose : undefined} > - {enableDismiss ? ( - - ) : ( - - )} - - + - + ) : ( + + )} + - {children} - + + + {children} + + - + ); }; @@ -122,18 +123,16 @@ export const RawBottomDialog: React.FC = ({ open, onClose, children }; const styles = StyleSheet.create({ - backdrop: { + root: { flex: 1, - backgroundColor: 'rgba(0,0,0,0.3)', + justifyContent: 'flex-end', }, disabledBackdrop: { pointerEvents: 'none', + backgroundColor: 'rgba(0,0,0,0.3)', }, dialog: { - position: 'absolute', - left: 0, - right: 0, - bottom: 0, + width: '100%', backgroundColor: '#fff', borderTopLeftRadius: 18, borderTopRightRadius: 18, @@ -155,16 +154,18 @@ const styles = StyleSheet.create({ marginTop: 12, marginBottom: 8, }, - keyboardAvoidingContainer: { + keyboardAvoider: { flex: 1, width: '100%', + justifyContent: 'flex-end', }, scrollContainer: { - flex: 1, + flexGrow: 0, + flexShrink: 1, width: '100%', }, scrollContent: { - flexGrow: 1, + flexGrow: 0, paddingBottom: Platform.OS === 'ios' ? 40 : 20, // Extra padding for iOS keyboard }, });