Skip to content

Commit

Permalink
[BugFix] Hide modal through onDismiss callback
Browse files Browse the repository at this point in the history
**Current behavior**: When user presses outside of modal, it gets dismissed internally regardless of whether app logic wants to close the modal and then user provided callback is invoked. This results in flicker - internal close and then immediate open due to `visible` state still `true` on modal if the app logic doesn't dismiss the modal immediately. Flicker is also caused if there are frame delays between user callback being invoked and `visible` state being set

**New Behavior**: Initiate dismiss modal only when app logic sets `visible` state to false

**Steps to reproduce bug**: Pass empty function as `onDismiss` callback and press outside of modal - modal flickers
  • Loading branch information
mdaamir151 authored Jan 2, 2025
1 parent 2827b9c commit e48550e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/components/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -206,14 +206,14 @@ function Modal({
accessibilityViewIsModal
accessibilityLiveRegion="polite"
style={StyleSheet.absoluteFill}
onAccessibilityEscape={hideModal}
onAccessibilityEscape={onDismissCallback}
testID={testID}
>
<AnimatedPressable
accessibilityLabel={overlayAccessibilityLabel}
accessibilityRole="button"
disabled={!dismissable}
onPress={dismissable ? hideModal : undefined}
onPress={dismissable ? onDismissCallback : undefined}
importantForAccessibility="no"
style={[
styles.backdrop,
Expand Down

0 comments on commit e48550e

Please sign in to comment.