From ca72cdb445ab2f41e24a954dbb3a94ebc1777322 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20V=C3=A9lez?= Date: Mon, 16 Dec 2024 16:35:18 -0500 Subject: [PATCH] MM-60733 - tap reply button loses focus on subsequent clicks (#29501) * MM-60733 - tap reply button lost focus * add pr feedback, have the own effect for selectedPostFocussedAt * remove function from dep array --- .../advanced_text_editor/advanced_text_editor.tsx | 11 ++++++++++- .../src/components/common/comment_icon.tsx | 12 +++++++----- .../src/components/post/post_component.tsx | 6 ++++-- .../channels/src/components/post/post_options.tsx | 15 ++++++++------- .../src/components/rhs_thread/rhs_thread.tsx | 2 +- 5 files changed, 30 insertions(+), 16 deletions(-) diff --git a/webapp/channels/src/components/advanced_text_editor/advanced_text_editor.tsx b/webapp/channels/src/components/advanced_text_editor/advanced_text_editor.tsx index 34b06437deb4..e9980f5c80ca 100644 --- a/webapp/channels/src/components/advanced_text_editor/advanced_text_editor.tsx +++ b/webapp/channels/src/components/advanced_text_editor/advanced_text_editor.tsx @@ -21,7 +21,7 @@ import * as GlobalActions from 'actions/global_actions'; import {actionOnGlobalItemsWithPrefix} from 'actions/storage'; import type {SubmitPostReturnType} from 'actions/views/create_comment'; import {removeDraft, updateDraft} from 'actions/views/drafts'; -import {makeGetDraft} from 'selectors/rhs'; +import {getSelectedPostFocussedAt, makeGetDraft} from 'selectors/rhs'; import {connectionErrorCount} from 'selectors/views/system'; import LocalStorageStore from 'stores/local_storage_store'; @@ -122,6 +122,7 @@ const AdvancedTextEditor = ({ const teammateId = useSelector((state: GlobalState) => getDirectChannel(state, channelId)?.teammate_id || ''); const teammateDisplayName = useSelector((state: GlobalState) => (teammateId ? getDisplayName(state, teammateId) : '')); const showDndWarning = useSelector((state: GlobalState) => (teammateId ? getStatusForUserId(state, teammateId) === UserStatuses.DND : false)); + const selectedPostFocussedAt = useSelector((state: GlobalState) => getSelectedPostFocussedAt(state)); const canPost = useSelector((state: GlobalState) => { const channel = getChannel(state, channelId); @@ -409,6 +410,14 @@ const AdvancedTextEditor = ({ } }, [showPreview]); + // Focus textbox when selectedPostFocussedAt changes + useEffect(() => { + if (selectedPostFocussedAt) { + focusTextbox(); + } + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [selectedPostFocussedAt]); + // Remove show preview when we switch channels or posts useEffect(() => { setShowPreview(false); diff --git a/webapp/channels/src/components/common/comment_icon.tsx b/webapp/channels/src/components/common/comment_icon.tsx index 71e8b3afa88a..91522ea6cb49 100644 --- a/webapp/channels/src/components/common/comment_icon.tsx +++ b/webapp/channels/src/components/common/comment_icon.tsx @@ -41,16 +41,18 @@ const CommentIcon = ({ iconStyle = `${iconStyle} ${searchStyle}`; } + const replyTitle = intl.formatMessage({ + id: 'post_info.comment_icon.tooltip.reply', + defaultMessage: 'Reply', + }); + return (