fix(editor): restore focus to main textbox after editing a post (#35518)

After editing a post, the main textbox now properly regains focus.
The fix uses the stored refocusId to focus the correct textbox element
(post_textbox or reply_textbox) before unsetting edit mode.

Co-authored-by: Mattermost Build <build@mattermost.com>
This commit is contained in:
Br1an
2026-04-16 09:28:34 +05:30
committed by GitHub
co-authored by Mattermost Build
parent d16579964c
commit 7bd18f5dec
@@ -119,6 +119,8 @@ const useSubmit = (
return haveIChannelPermission(state, channel.team_id, channel.id, Permissions.USE_CHANNEL_MENTIONS);
});
const editingPostRefocusId = useSelector((state: GlobalState) => state.views.posts.editingPost.refocusId);
const showPostDeletedModal = useCallback(() => {
dispatch(openModal({
modalId: ModalIdentifiers.POST_DELETED_MODAL,
@@ -236,6 +238,11 @@ const useSubmit = (
}
if (isInEditMode) {
// Refocus the main textbox before unsetting edit mode
if (editingPostRefocusId) {
const element = document.getElementById(editingPostRefocusId);
element?.focus();
}
dispatch(unsetEditingPost());
}
@@ -258,6 +265,7 @@ const useSubmit = (
channelId,
isInEditMode,
handleFileChange,
editingPostRefocusId,
]);
const setUpdatedFileIds = useCallback((draft: PostDraft) => {