From ddbfebbaa0e17827e2517eccb1f6d2dbe287c579 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 19 Nov 2021 17:15:15 +0000 Subject: [PATCH] Fix automatic composer focus, regressed by threads work (#7167) --- src/components/structures/LoggedInView.tsx | 6 ++--- .../views/emojipicker/ReactionPicker.tsx | 4 +-- .../views/rooms/SendMessageComposer.tsx | 4 +-- src/dispatcher/actions.ts | 4 +-- .../payloads/FocusComposerPayload.ts | 25 +++++++++++++++++++ 5 files changed, 34 insertions(+), 9 deletions(-) create mode 100644 src/dispatcher/payloads/FocusComposerPayload.ts diff --git a/src/components/structures/LoggedInView.tsx b/src/components/structures/LoggedInView.tsx index 88756a334b..69fe5c6316 100644 --- a/src/components/structures/LoggedInView.tsx +++ b/src/components/structures/LoggedInView.tsx @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -import * as React from 'react'; +import React, { ClipboardEvent } from 'react'; import { MatrixClient } from 'matrix-js-sdk/src/client'; import { MatrixEvent } from 'matrix-js-sdk/src/models/event'; @@ -415,9 +415,9 @@ class LoggedInView extends React.Component { }); }; - private onPaste = (ev) => { + private onPaste = (ev: ClipboardEvent) => { let canReceiveInput = false; - let element = ev.target; + let element = ev.currentTarget; // test for all parents because the target can be a child of a contenteditable element while (!canReceiveInput && element) { canReceiveInput = canElementReceiveInput(element); diff --git a/src/components/views/emojipicker/ReactionPicker.tsx b/src/components/views/emojipicker/ReactionPicker.tsx index e129b45c9a..1f74879681 100644 --- a/src/components/views/emojipicker/ReactionPicker.tsx +++ b/src/components/views/emojipicker/ReactionPicker.tsx @@ -94,7 +94,7 @@ class ReactionPicker extends React.Component { this.props.mxEvent.getRoomId(), myReactions[reaction], ); - dis.dispatch({ action: Action.FocusAComposer }); + dis.fire(Action.FocusAComposer); // Tell the emoji picker not to bump this in the more frequently used list. return false; } else { @@ -106,7 +106,7 @@ class ReactionPicker extends React.Component { }, }); dis.dispatch({ action: "message_sent" }); - dis.dispatch({ action: Action.FocusAComposer }); + dis.fire(Action.FocusAComposer); return true; } }; diff --git a/src/components/views/rooms/SendMessageComposer.tsx b/src/components/views/rooms/SendMessageComposer.tsx index 3b1db6bb90..e6ec92cffb 100644 --- a/src/components/views/rooms/SendMessageComposer.tsx +++ b/src/components/views/rooms/SendMessageComposer.tsx @@ -56,7 +56,7 @@ import ErrorDialog from "../dialogs/ErrorDialog"; import QuestionDialog from "../dialogs/QuestionDialog"; import { ActionPayload } from "../../../dispatcher/payloads"; import { decorateStartSendingTime, sendRoundTripMetric } from "../../../sendTimePerformanceMetrics"; -import RoomContext from '../../../contexts/RoomContext'; +import RoomContext, { TimelineRenderingType } from '../../../contexts/RoomContext'; import DocumentPosition from "../../../editor/position"; import { ComposerType } from "../../../dispatcher/payloads/ComposerInsertPayload"; @@ -597,7 +597,7 @@ export class SendMessageComposer extends React.Component