diff --git a/src/app/components/editor/Editor.tsx b/src/app/components/editor/Editor.tsx index bd848dd5..f6177817 100644 --- a/src/app/components/editor/Editor.tsx +++ b/src/app/components/editor/Editor.tsx @@ -16,6 +16,7 @@ import { RenderLeafProps, RenderElementProps, RenderPlaceholderProps, + ReactEditor, } from 'slate-react'; import { withHistory } from 'slate-history'; import { BlockType } from './types'; @@ -23,6 +24,7 @@ import { RenderElement, RenderLeaf } from './Elements'; import { CustomElement } from './slate'; import * as css from './Editor.css'; import { toggleKeyboardShortcut } from './keyboard'; +import { mobileOrTablet } from '../../utils/user-agent'; const initialValue: CustomElement[] = [ { @@ -99,7 +101,13 @@ export const CustomEditor = forwardRef( const handleKeydown: KeyboardEventHandler = useCallback( (evt) => { + // mobile ignores config option + if (mobileOrTablet() && evt.key === 'Enter' && !evt.shiftKey) { + return; + } + onKeyDown?.(evt); + const shortcutToggled = toggleKeyboardShortcut(editor, evt); if (shortcutToggled) evt.preventDefault(); }, @@ -146,6 +154,8 @@ export const CustomEditor = forwardRef( onKeyDown={handleKeydown} onKeyUp={onKeyUp} onPaste={onPaste} + // keeps focus after pressing send. + onBlur={() => { if (mobileOrTablet()) ReactEditor.focus(editor); }} /> {after && ( diff --git a/src/app/features/room/RoomInput.tsx b/src/app/features/room/RoomInput.tsx index 793ba082..52f46ad7 100644 --- a/src/app/features/room/RoomInput.tsx +++ b/src/app/features/room/RoomInput.tsx @@ -309,6 +309,8 @@ export const RoomInput = forwardRef( resetEditor(editor); resetEditorHistory(editor); sendTypingStatus(false); + + return; } @@ -643,7 +645,7 @@ export const RoomInput = forwardRef( )} - + e.preventDefault()} variant="SurfaceVariant" size="300" radii="300"> diff --git a/src/app/features/settings/general/General.tsx b/src/app/features/settings/general/General.tsx index b861a060..d5db61a1 100644 --- a/src/app/features/settings/general/General.tsx +++ b/src/app/features/settings/general/General.tsx @@ -718,9 +718,8 @@ function Editor() { } /> diff --git a/vite.config.js b/vite.config.js index fe1787da..0361dad1 100644 --- a/vite.config.js +++ b/vite.config.js @@ -1,5 +1,6 @@ import { defineConfig } from 'vite'; import react from '@vitejs/plugin-react'; +import svgr from 'vite-plugin-svgr'; import { wasm } from '@rollup/plugin-wasm'; import { viteStaticCopy } from 'vite-plugin-static-copy'; import { vanillaExtractPlugin } from '@vanilla-extract/vite-plugin'; @@ -10,7 +11,6 @@ import { VitePWA } from 'vite-plugin-pwa'; import fs from 'fs'; import path from 'path'; import buildConfig from './build.config'; -import svgr from 'vite-plugin-svgr'; const copyFiles = { targets: [