Handle focusing multiple composers
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>pull/21833/head
parent
14687f3630
commit
7734f8aeef
|
@ -832,6 +832,22 @@ export default class RoomView extends React.Component<IProps, IState> {
|
|||
break;
|
||||
}
|
||||
|
||||
case Action.FocusAComposer: {
|
||||
// re-dispatch to the correct composer
|
||||
if (this.state.editState) {
|
||||
dis.dispatch({
|
||||
...payload,
|
||||
action: Action.FocusEditMessageComposer,
|
||||
});
|
||||
} else {
|
||||
dis.dispatch({
|
||||
...payload,
|
||||
action: Action.FocusComposer,
|
||||
});
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case "scroll_to_bottom":
|
||||
this.messagePanel?.jumpToLiveTimeline();
|
||||
break;
|
||||
|
|
|
@ -94,7 +94,7 @@ class ReactionPicker extends React.Component<IProps, IState> {
|
|||
this.props.mxEvent.getRoomId(),
|
||||
myReactions[reaction],
|
||||
);
|
||||
dis.dispatch({ action: Action.FocusComposer });
|
||||
dis.dispatch({ action: 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<IProps, IState> {
|
|||
},
|
||||
});
|
||||
dis.dispatch({ action: "message_sent" });
|
||||
dis.dispatch({ action: Action.FocusComposer });
|
||||
dis.dispatch({ action: Action.FocusAComposer });
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -452,6 +452,8 @@ export default class EditMessageComposer extends React.Component<IProps, IState>
|
|||
} else if (payload.text) {
|
||||
this.editorRef.current?.insertPlaintext(payload.text);
|
||||
}
|
||||
} else if (payload.action === Action.FocusEditMessageComposer && this.editorRef.current) {
|
||||
this.editorRef.current.focus();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -56,10 +56,22 @@ export enum Action {
|
|||
CheckUpdates = "check_updates",
|
||||
|
||||
/**
|
||||
* Focuses the user's cursor to the composer. No additional payload information required.
|
||||
* Focuses the user's cursor to the send message composer. No additional payload information required.
|
||||
*/
|
||||
FocusComposer = "focus_composer",
|
||||
|
||||
/**
|
||||
* Focuses the user's cursor to the edit message composer. No additional payload information required.
|
||||
*/
|
||||
FocusEditMessageComposer = "focus_edit_message_composer",
|
||||
|
||||
/**
|
||||
* Focuses the user's cursor to the edit message composer or send message
|
||||
* composer based on the current edit state. No additional payload
|
||||
* information required.
|
||||
*/
|
||||
FocusAComposer = "focus_a_composer",
|
||||
|
||||
/**
|
||||
* Opens the user menu (previously known as the top left menu). No additional payload information required.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue