Bluesky app fork with some witchin' additions 💫
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Web: fix Edit Profile discard warning when pressing backdrop (#8824)

* Web: fix Edit Profile discard warning

* cleanup imports

authored by

Bartosz Kaszubowski and committed by
GitHub
8dcf1825 c12fd448

+27 -28
+7 -3
src/components/Dialog/index.web.tsx
··· 2 2 import { 3 3 FlatList, 4 4 type FlatListProps, 5 + type GestureResponderEvent, 5 6 type StyleProp, 6 7 TouchableWithoutFeedback, 7 8 View, ··· 75 76 [control.id, onClose, setDialogIsOpen], 76 77 ) 77 78 78 - const handleBackgroundPress = React.useCallback(async () => { 79 - close() 80 - }, [close]) 79 + const handleBackgroundPress = React.useCallback( 80 + async (e: GestureResponderEvent) => { 81 + webOptions?.onBackgroundPress ? webOptions.onBackgroundPress(e) : close() 82 + }, 83 + [webOptions, close], 84 + ) 81 85 82 86 useImperativeHandle( 83 87 control.ref,
+11 -10
src/components/Dialog/types.ts
··· 1 - import React from 'react' 2 - import type { 3 - AccessibilityProps, 4 - GestureResponderEvent, 5 - ScrollViewProps, 1 + import { 2 + type AccessibilityProps, 3 + type GestureResponderEvent, 4 + type ScrollViewProps, 5 + type StyleProp, 6 + type ViewStyle, 6 7 } from 'react-native' 7 - import {ViewStyle} from 'react-native' 8 - import {StyleProp} from 'react-native' 8 + import type React from 'react' 9 9 10 - import {ViewStyleProp} from '#/alf' 11 - import {BottomSheetViewProps} from '../../../modules/bottom-sheet' 12 - import {BottomSheetSnapPoint} from '../../../modules/bottom-sheet/src/BottomSheet.types' 10 + import {type ViewStyleProp} from '#/alf' 11 + import {type BottomSheetViewProps} from '../../../modules/bottom-sheet' 12 + import {type BottomSheetSnapPoint} from '../../../modules/bottom-sheet/src/BottomSheet.types' 13 13 14 14 type A11yProps = Required<AccessibilityProps> 15 15 ··· 64 64 nativeOptions?: Omit<BottomSheetViewProps, 'children'> 65 65 webOptions?: { 66 66 alignCenter?: boolean 67 + onBackgroundPress?: (e: GestureResponderEvent) => void 67 68 } 68 69 testID?: string 69 70 }
+9 -15
src/screens/Profile/Header/EditProfileDialog.tsx
··· 8 8 import {cleanError} from '#/lib/strings/errors' 9 9 import {useWarnMaxGraphemeCount} from '#/lib/strings/helpers' 10 10 import {logger} from '#/logger' 11 - import {isWeb} from '#/platform/detection' 12 11 import {type ImageMeta} from '#/state/gallery' 13 12 import {useProfileUpdateMutation} from '#/state/queries/profile' 14 13 import {ErrorMessage} from '#/view/com/util/error/ErrorMessage' ··· 44 43 const cancelControl = Dialog.useDialogControl() 45 44 const [dirty, setDirty] = useState(false) 46 45 47 - // 'You might lose unsaved changes' warning 48 - useEffect(() => { 49 - if (isWeb && dirty) { 50 - const abortController = new AbortController() 51 - const {signal} = abortController 52 - window.addEventListener('beforeunload', evt => evt.preventDefault(), { 53 - signal, 54 - }) 55 - return () => { 56 - abortController.abort() 57 - } 58 - } 59 - }, [dirty]) 60 - 61 46 const onPressCancel = useCallback(() => { 62 47 if (dirty) { 63 48 cancelControl.open() ··· 72 57 nativeOptions={{ 73 58 preventDismiss: dirty, 74 59 minHeight: SCREEN_HEIGHT, 60 + }} 61 + webOptions={{ 62 + onBackgroundPress: () => { 63 + if (dirty) { 64 + cancelControl.open() 65 + } else { 66 + control.close() 67 + } 68 + }, 75 69 }} 76 70 testID="editProfileModal"> 77 71 <DialogInner