From 734b5be54cb68060b4c1e8d2d05c606c8e38805c Mon Sep 17 00:00:00 2001
From: Hedi Nasr <hedi.nasr.pro@gmail.com>
Date: Thu, 14 Nov 2024 14:50:25 +0100
Subject: [PATCH] fix(modal): dismiss keyboard on drag card modal

---
 core/src/components/modal/gestures/swipe-to-close.ts | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/core/src/components/modal/gestures/swipe-to-close.ts b/core/src/components/modal/gestures/swipe-to-close.ts
index 17ec454ff15..3b4c72efc3d 100644
--- a/core/src/components/modal/gestures/swipe-to-close.ts
+++ b/core/src/components/modal/gestures/swipe-to-close.ts
@@ -1,7 +1,7 @@
 import { getTimeGivenProgression } from '@utils/animation/cubic-bezier';
 import { isIonContent, findClosestIonContent, disableContentScrollY, resetContentScrollY } from '@utils/content';
 import { createGesture } from '@utils/gesture';
-import { clamp, getElementRoot } from '@utils/helpers';
+import { clamp, getElementRoot, raf } from '@utils/helpers';
 import { OVERLAY_GESTURE_PRIORITY } from '@utils/overlays';
 
 import type { Animation } from '../../../interface';
@@ -141,6 +141,14 @@ export const createSwipeToCloseGesture = (
       disableContentScrollY(contentEl);
     }
 
+    raf(() => {
+      /**
+       * Dismisses the open keyboard when the card drag gesture is started.
+       * Sets the focus onto the modal element.
+       */
+      el.focus();
+    });
+
     animation.progressStart(true, isOpen ? 1 : 0);
   };