Skip to content

Commit e48550e

Browse files
authored
[BugFix] Hide modal through onDismiss callback
**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
1 parent 2827b9c commit e48550e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/components/Modal.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,14 +206,14 @@ function Modal({
206206
accessibilityViewIsModal
207207
accessibilityLiveRegion="polite"
208208
style={StyleSheet.absoluteFill}
209-
onAccessibilityEscape={hideModal}
209+
onAccessibilityEscape={onDismissCallback}
210210
testID={testID}
211211
>
212212
<AnimatedPressable
213213
accessibilityLabel={overlayAccessibilityLabel}
214214
accessibilityRole="button"
215215
disabled={!dismissable}
216-
onPress={dismissable ? hideModal : undefined}
216+
onPress={dismissable ? onDismissCallback : undefined}
217217
importantForAccessibility="no"
218218
style={[
219219
styles.backdrop,

0 commit comments

Comments
 (0)