Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(mobile): spurious virtual keyboard signal (#3349)

Peter Chinmanb02383245548
diff --git a/js/app/packages/app/component/useAppSquishHandlers.ts b/js/app/packages/app/component/useAppSquishHandlers.ts
index 55fc090591..cd43007194 100644
--- a/js/app/packages/app/component/useAppSquishHandlers.ts
+++ b/js/app/packages/app/component/useAppSquishHandlers.ts
@@ -7,6 +7,16 @@ import { isEditableInput } from '@core/util/isEditableInput';
import { isIOS } from '@solid-primitives/platform';
import { onCleanup, onMount } from 'solid-js';
+function resetVirtualKeyboardState() {
+ setVirtualKeyboardVisible(false);
+ setVirtualKeyboardHeight(0);
+ document.documentElement.style.setProperty('--dvh', '1dvh');
+ document.documentElement.style.setProperty(
+ '--virtual-keyboard-height',
+ '0px'
+ );
+}
+
/**
* Functionality for responding to virtual keyboard appearance in web app and native mobile app.
*/
@@ -31,13 +41,16 @@ export function useAppSquishHandlers() {
};
const handleKeyboardWillHide = () => {
- setVirtualKeyboardVisible(false);
- setVirtualKeyboardHeight(0);
- document.documentElement.style.setProperty('--dvh', '1dvh');
- document.documentElement.style.setProperty(
- '--virtual-keyboard-height',
- '0px'
- );
+ resetVirtualKeyboardState();
+ };
+
+ const handleVisibilityChange = () => {
+ if (
+ document.visibilityState === 'visible' &&
+ !isEditableInput(document.activeElement)
+ ) {
+ resetVirtualKeyboardState();
+ }
};
onMount(() => {
@@ -48,10 +61,15 @@ export function useAppSquishHandlers() {
document.documentElement.style.setProperty('--dvh', '1dvh');
window.addEventListener('keyboardWillShow', handleKeyboardWillShow);
window.addEventListener('keyboardWillHide', handleKeyboardWillHide);
+ document.addEventListener('visibilitychange', handleVisibilityChange);
onCleanup(() => {
window.removeEventListener('keyboardWillShow', handleKeyboardWillShow);
window.removeEventListener('keyboardWillHide', handleKeyboardWillHide);
+ document.removeEventListener(
+ 'visibilitychange',
+ handleVisibilityChange
+ );
});
});
} else if (isIOS) {
diff --git a/js/app/packages/channel/Channel/create-inline-input-keyboard-handler.ts b/js/app/packages/channel/Channel/create-inline-input-keyboard-handler.ts
index ddee902950..e7c59d0216 100644
--- a/js/app/packages/channel/Channel/create-inline-input-keyboard-handler.ts
+++ b/js/app/packages/channel/Channel/create-inline-input-keyboard-handler.ts
@@ -98,9 +98,7 @@ export function createInlineInputKeyboardHandler(
on(virtualKeyboardVisible, () => {
if (!isTouchDevice()) return;
if (!virtualKeyboardVisible()) {
- if (activeInputContainer) {
- reset();
- }
+ reset();
return;
}
// Mobile web only: scroll active input into view when keyboard appears.