fix: Fixed issue where moving the floating keyboard on iPad would lead to blank space on screen
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
import { ApplicationEvent, ReactNativeToWebEvent } from '@standardnotes/snjs'
|
import { ApplicationEvent, ReactNativeToWebEvent } from '@standardnotes/snjs'
|
||||||
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||||
import { Button, Keyboard, Platform, Text, View } from 'react-native'
|
import { Button, Dimensions, Keyboard, Platform, Text, View } from 'react-native'
|
||||||
import VersionInfo from 'react-native-version-info'
|
import VersionInfo from 'react-native-version-info'
|
||||||
import { WebView, WebViewMessageEvent } from 'react-native-webview'
|
import { WebView, WebViewMessageEvent } from 'react-native-webview'
|
||||||
import { OnShouldStartLoadWithRequest } from 'react-native-webview/lib/WebViewTypes'
|
import { OnShouldStartLoadWithRequest } from 'react-native-webview/lib/WebViewTypes'
|
||||||
@@ -84,7 +84,11 @@ const MobileWebAppContents = ({ destroyAndReload }: { destroyAndReload: () => vo
|
|||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
reactNativeEvent: ReactNativeToWebEvent.KeyboardFrameWillChange,
|
reactNativeEvent: ReactNativeToWebEvent.KeyboardFrameWillChange,
|
||||||
messageType: 'event',
|
messageType: 'event',
|
||||||
messageData: { height: e.endCoordinates.height, contentHeight: e.endCoordinates.screenY },
|
messageData: {
|
||||||
|
height: e.endCoordinates.height,
|
||||||
|
contentHeight: e.endCoordinates.screenY,
|
||||||
|
isFloatingKeyboard: e.endCoordinates.width !== Dimensions.get('window').width,
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -14,7 +14,11 @@ export interface WebApplicationInterface extends ApplicationInterface {
|
|||||||
handleMobileLosingFocusEvent(): Promise<void>
|
handleMobileLosingFocusEvent(): Promise<void>
|
||||||
handleMobileResumingFromBackgroundEvent(): Promise<void>
|
handleMobileResumingFromBackgroundEvent(): Promise<void>
|
||||||
handleMobileColorSchemeChangeEvent(): void
|
handleMobileColorSchemeChangeEvent(): void
|
||||||
handleMobileKeyboardWillChangeFrameEvent(frame: { height: number; contentHeight: number }): void
|
handleMobileKeyboardWillChangeFrameEvent(frame: {
|
||||||
|
height: number
|
||||||
|
contentHeight: number
|
||||||
|
isFloatingKeyboard: boolean
|
||||||
|
}): void
|
||||||
handleMobileKeyboardDidChangeFrameEvent(frame: { height: number; contentHeight: number }): void
|
handleMobileKeyboardDidChangeFrameEvent(frame: { height: number; contentHeight: number }): void
|
||||||
handleReceivedFileEvent(file: { name: string; mimeType: string; data: string }): void
|
handleReceivedFileEvent(file: { name: string; mimeType: string; data: string }): void
|
||||||
handleReceivedTextEvent(item: { text: string; title?: string }): Promise<void>
|
handleReceivedTextEvent(item: { text: string; title?: string }): Promise<void>
|
||||||
|
|||||||
@@ -373,10 +373,17 @@ export class WebApplication extends SNApplication implements WebApplicationInter
|
|||||||
void this.getThemeService().handleMobileColorSchemeChangeEvent()
|
void this.getThemeService().handleMobileColorSchemeChangeEvent()
|
||||||
}
|
}
|
||||||
|
|
||||||
handleMobileKeyboardWillChangeFrameEvent(frame: { height: number; contentHeight: number }): void {
|
handleMobileKeyboardWillChangeFrameEvent(frame: {
|
||||||
|
height: number
|
||||||
|
contentHeight: number
|
||||||
|
isFloatingKeyboard: boolean
|
||||||
|
}): void {
|
||||||
if (frame.contentHeight > 0) {
|
if (frame.contentHeight > 0) {
|
||||||
setCustomViewportHeight(frame.contentHeight, 'px', true)
|
setCustomViewportHeight(frame.contentHeight, 'px', true)
|
||||||
}
|
}
|
||||||
|
if (frame.isFloatingKeyboard) {
|
||||||
|
setCustomViewportHeight(100, 'vh', true)
|
||||||
|
}
|
||||||
this.notifyWebEvent(WebAppEvent.MobileKeyboardWillChangeFrame, frame)
|
this.notifyWebEvent(WebAppEvent.MobileKeyboardWillChangeFrame, frame)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ export class MobileWebReceiver {
|
|||||||
break
|
break
|
||||||
case ReactNativeToWebEvent.KeyboardFrameWillChange:
|
case ReactNativeToWebEvent.KeyboardFrameWillChange:
|
||||||
void this.application.handleMobileKeyboardWillChangeFrameEvent(
|
void this.application.handleMobileKeyboardWillChangeFrameEvent(
|
||||||
messageData as { height: number; contentHeight: number },
|
messageData as { height: number; contentHeight: number; isFloatingKeyboard: boolean },
|
||||||
)
|
)
|
||||||
break
|
break
|
||||||
case ReactNativeToWebEvent.KeyboardFrameDidChange:
|
case ReactNativeToWebEvent.KeyboardFrameDidChange:
|
||||||
|
|||||||
Reference in New Issue
Block a user