From 928b109ae64db3679927eca211c112df3b3bb04b Mon Sep 17 00:00:00 2001 From: HaecheonLee Date: Fri, 10 May 2024 04:14:21 -0400 Subject: [PATCH] enh: resolve @ts-expect-error issues (#58) --- src/components/ChatBotContainer.tsx | 12 +++++----- src/components/ChatBotInput/ChatBotInput.tsx | 6 ++--- .../ChatBotInput/VoiceButton/VoiceButton.tsx | 3 +-- src/services/VoiceService.tsx | 2 +- types/global.d.ts | 22 +++++++++++++++++++ 5 files changed, 33 insertions(+), 12 deletions(-) create mode 100644 types/global.d.ts diff --git a/src/components/ChatBotContainer.tsx b/src/components/ChatBotContainer.tsx index a6bc0065..cac23774 100644 --- a/src/components/ChatBotContainer.tsx +++ b/src/components/ChatBotContainer.tsx @@ -147,13 +147,15 @@ const ChatBotContainer = ({ flow }: { flow: Flow }) => { if (isDesktop || botOptions.theme?.embedded) { return; } - - if ("virtualKeyboard" in navigator) { - // @ts-expect-error virtualkeyboard type unknown + + if (navigator.virtualKeyboard) { navigator.virtualKeyboard.overlaysContent = true; - // @ts-expect-error virtualkeyboard type unknown navigator.virtualKeyboard.addEventListener("geometrychange", (event) => { - const { x, y, width, height } = event.target.boundingRect; + if (!event.target) { + return; + } + + const { x, y, width, height } = (event.target as VirtualKeyboard).boundingRect; // width does not need adjustments so only height is adjusted if (x == 0 && y == 0 && width == 0 && height == 0) { // delay added as it takes time for keyboard to appear and resize the viewport height diff --git a/src/components/ChatBotInput/ChatBotInput.tsx b/src/components/ChatBotInput/ChatBotInput.tsx index eb8aeb15..5208102a 100644 --- a/src/components/ChatBotInput/ChatBotInput.tsx +++ b/src/components/ChatBotInput/ChatBotInput.tsx @@ -181,8 +181,7 @@ const ChatBotInput = ({ {/* textarea intentionally does not use the disabled property to prevent keyboard from closing on mobile */} {textAreaSensitiveMode && botOptions.sensitiveInfo?.maskInTextArea ? } type="password" className="rcb-chat-input-textarea" style={textAreaDisabled @@ -196,8 +195,7 @@ const ChatBotInput = ({ /> :