You've already forked matrix-react-sdk
							
							
				mirror of
				https://github.com/matrix-org/matrix-react-sdk.git
				synced 2025-11-03 00:33:22 +03:00 
			
		
		
		
	Fix unexpected composer growing (#9889)
* Stop the enter event propagation when a message is sent to avoid the composer to grow. * Update @matrix-org/matrix-wysiwyg to 0.16.0
This commit is contained in:
		@@ -57,7 +57,7 @@
 | 
				
			|||||||
    "dependencies": {
 | 
					    "dependencies": {
 | 
				
			||||||
        "@babel/runtime": "^7.12.5",
 | 
					        "@babel/runtime": "^7.12.5",
 | 
				
			||||||
        "@matrix-org/analytics-events": "^0.3.0",
 | 
					        "@matrix-org/analytics-events": "^0.3.0",
 | 
				
			||||||
        "@matrix-org/matrix-wysiwyg": "^0.14.0",
 | 
					        "@matrix-org/matrix-wysiwyg": "^0.16.0",
 | 
				
			||||||
        "@matrix-org/react-sdk-module-api": "^0.0.3",
 | 
					        "@matrix-org/react-sdk-module-api": "^0.0.3",
 | 
				
			||||||
        "@sentry/browser": "^7.0.0",
 | 
					        "@sentry/browser": "^7.0.0",
 | 
				
			||||||
        "@sentry/tracing": "^7.0.0",
 | 
					        "@sentry/tracing": "^7.0.0",
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
 | 
				
			|||||||
limitations under the License.
 | 
					limitations under the License.
 | 
				
			||||||
*/
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import { WysiwygInputEvent } from "@matrix-org/matrix-wysiwyg";
 | 
					import { WysiwygEvent } from "@matrix-org/matrix-wysiwyg";
 | 
				
			||||||
import { useCallback } from "react";
 | 
					import { useCallback } from "react";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import { useSettingValue } from "../../../../../hooks/useSettings";
 | 
					import { useSettingValue } from "../../../../../hooks/useSettings";
 | 
				
			||||||
@@ -22,12 +22,20 @@ import { useSettingValue } from "../../../../../hooks/useSettings";
 | 
				
			|||||||
export function useInputEventProcessor(onSend: () => void) {
 | 
					export function useInputEventProcessor(onSend: () => void) {
 | 
				
			||||||
    const isCtrlEnter = useSettingValue<boolean>("MessageComposerInput.ctrlEnterToSend");
 | 
					    const isCtrlEnter = useSettingValue<boolean>("MessageComposerInput.ctrlEnterToSend");
 | 
				
			||||||
    return useCallback(
 | 
					    return useCallback(
 | 
				
			||||||
        (event: WysiwygInputEvent) => {
 | 
					        (event: WysiwygEvent) => {
 | 
				
			||||||
            if (event instanceof ClipboardEvent) {
 | 
					            if (event instanceof ClipboardEvent) {
 | 
				
			||||||
                return event;
 | 
					                return event;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if ((event.inputType === "insertParagraph" && !isCtrlEnter) || event.inputType === "sendMessage") {
 | 
					            const isKeyboardEvent = event instanceof KeyboardEvent;
 | 
				
			||||||
 | 
					            const isEnterPress =
 | 
				
			||||||
 | 
					                !isCtrlEnter && (isKeyboardEvent ? event.key === "Enter" : event.inputType === "insertParagraph");
 | 
				
			||||||
 | 
					            // sendMessage is sent when ctrl+enter is pressed
 | 
				
			||||||
 | 
					            const isSendMessage = !isKeyboardEvent && event.inputType === "sendMessage";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (isEnterPress || isSendMessage) {
 | 
				
			||||||
 | 
					                event.stopPropagation?.();
 | 
				
			||||||
 | 
					                event.preventDefault?.();
 | 
				
			||||||
                onSend();
 | 
					                onSend();
 | 
				
			||||||
                return null;
 | 
					                return null;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1589,10 +1589,10 @@
 | 
				
			|||||||
  resolved "https://registry.yarnpkg.com/@matrix-org/matrix-sdk-crypto-js/-/matrix-sdk-crypto-js-0.1.0-alpha.2.tgz#a09d0fea858e817da971a3c9f904632ef7b49eb6"
 | 
					  resolved "https://registry.yarnpkg.com/@matrix-org/matrix-sdk-crypto-js/-/matrix-sdk-crypto-js-0.1.0-alpha.2.tgz#a09d0fea858e817da971a3c9f904632ef7b49eb6"
 | 
				
			||||||
  integrity sha512-oVkBCh9YP7H9i4gAoQbZzswniczfo/aIptNa4dxRi4Ff9lSvUCFv6Hvzi7C+90c0/PWZLXjIDTIAWZYmwyd2fA==
 | 
					  integrity sha512-oVkBCh9YP7H9i4gAoQbZzswniczfo/aIptNa4dxRi4Ff9lSvUCFv6Hvzi7C+90c0/PWZLXjIDTIAWZYmwyd2fA==
 | 
				
			||||||
 | 
					
 | 
				
			||||||
"@matrix-org/matrix-wysiwyg@^0.14.0":
 | 
					"@matrix-org/matrix-wysiwyg@^0.16.0":
 | 
				
			||||||
  version "0.14.0"
 | 
					  version "0.16.0"
 | 
				
			||||||
  resolved "https://registry.yarnpkg.com/@matrix-org/matrix-wysiwyg/-/matrix-wysiwyg-0.14.0.tgz#359fabf5af403b3f128fe6ede3bff9754a9e18c4"
 | 
					  resolved "https://registry.yarnpkg.com/@matrix-org/matrix-wysiwyg/-/matrix-wysiwyg-0.16.0.tgz#2eb81899cedc740f522bd7c2839bd9151d67a28e"
 | 
				
			||||||
  integrity sha512-iSwIR7kS/zwAzy/8S5cUMv2aceoJl/vIGhqmY9hSU0gVyzmsyaVnx00uNMvVDBUFiiPT2gonN8R3+dxg58TPaQ==
 | 
					  integrity sha512-w+/bUQ5x4lVRncrYSmdxy5ww4kkgXeSg4aFfby9c7c6o/+o4gfV6/XBdoJ71nhStyIYIweKAz8i3zA3rKonyvw==
 | 
				
			||||||
 | 
					
 | 
				
			||||||
"@matrix-org/olm@https://gitlab.matrix.org/api/v4/projects/27/packages/npm/@matrix-org/olm/-/@matrix-org/olm-3.2.14.tgz":
 | 
					"@matrix-org/olm@https://gitlab.matrix.org/api/v4/projects/27/packages/npm/@matrix-org/olm/-/@matrix-org/olm-3.2.14.tgz":
 | 
				
			||||||
  version "3.2.14"
 | 
					  version "3.2.14"
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user