Skip to content

Commit

Permalink
fix: handle dismissible false with onPress
Browse files Browse the repository at this point in the history
  • Loading branch information
gunnartorfis committed Sep 18, 2024
1 parent 7c9033b commit c10b936
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion example/src/ToastDemo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ export const ToastDemo: React.FC = () => {
title="OnPress action"
onPress={() => {
const id = toast.success('OnPress action', {
dismissible: true,
dismissible: false,
onPress: () => {
toast.dismiss(id);
setToastId(null);
Expand Down
5 changes: 2 additions & 3 deletions src/gestures.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,9 @@ export const ToastSwipeHandler: React.FC<
});

const tap = Gesture.Tap().onEnd(() => {
if (!enabled) {
return;
if (onPress) {
runOnJS(onPress)();
}
runOnJS(onPress)();
});

const animatedStyle = useAnimatedStyle(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/toast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ export const Toast = React.forwardRef<ToastRef, ToastProps>(
}
}}
onPress={() => onPress?.()}
enabled={onPress ? true : !promiseOptions && dismissible}
enabled={!promiseOptions && dismissible}
style={[toastContainerStyleCtx, styles?.toastContainer]}
className={cn(
classNamesCtx?.toastContainer,
Expand Down

0 comments on commit c10b936

Please sign in to comment.