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
Этот коммит содержится в:
@@ -21,7 +21,7 @@ import * as GlobalActions from 'actions/global_actions';
|
|||||||
import {actionOnGlobalItemsWithPrefix} from 'actions/storage';
|
import {actionOnGlobalItemsWithPrefix} from 'actions/storage';
|
||||||
import type {SubmitPostReturnType} from 'actions/views/create_comment';
|
import type {SubmitPostReturnType} from 'actions/views/create_comment';
|
||||||
import {removeDraft, updateDraft} from 'actions/views/drafts';
|
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 {connectionErrorCount} from 'selectors/views/system';
|
||||||
import LocalStorageStore from 'stores/local_storage_store';
|
import LocalStorageStore from 'stores/local_storage_store';
|
||||||
|
|
||||||
@@ -122,6 +122,7 @@ const AdvancedTextEditor = ({
|
|||||||
const teammateId = useSelector((state: GlobalState) => getDirectChannel(state, channelId)?.teammate_id || '');
|
const teammateId = useSelector((state: GlobalState) => getDirectChannel(state, channelId)?.teammate_id || '');
|
||||||
const teammateDisplayName = useSelector((state: GlobalState) => (teammateId ? getDisplayName(state, teammateId) : ''));
|
const teammateDisplayName = useSelector((state: GlobalState) => (teammateId ? getDisplayName(state, teammateId) : ''));
|
||||||
const showDndWarning = useSelector((state: GlobalState) => (teammateId ? getStatusForUserId(state, teammateId) === UserStatuses.DND : false));
|
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 canPost = useSelector((state: GlobalState) => {
|
||||||
const channel = getChannel(state, channelId);
|
const channel = getChannel(state, channelId);
|
||||||
@@ -409,6 +410,14 @@ const AdvancedTextEditor = ({
|
|||||||
}
|
}
|
||||||
}, [showPreview]);
|
}, [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
|
// Remove show preview when we switch channels or posts
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setShowPreview(false);
|
setShowPreview(false);
|
||||||
|
|||||||
@@ -41,16 +41,18 @@ const CommentIcon = ({
|
|||||||
iconStyle = `${iconStyle} ${searchStyle}`;
|
iconStyle = `${iconStyle} ${searchStyle}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const replyTitle = intl.formatMessage({
|
||||||
|
id: 'post_info.comment_icon.tooltip.reply',
|
||||||
|
defaultMessage: 'Reply',
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<WithTooltip
|
<WithTooltip
|
||||||
title={intl.formatMessage({
|
title={replyTitle}
|
||||||
id: 'post_info.comment_icon.tooltip.reply',
|
|
||||||
defaultMessage: 'Reply',
|
|
||||||
})}
|
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
id={`${location}_commentIcon_${postId}`}
|
id={`${location}_commentIcon_${postId}`}
|
||||||
aria-label={intl.formatMessage({id: 'post_info.comment_icon.tooltip.reply', defaultMessage: 'Reply'}).toLowerCase()}
|
aria-label={replyTitle.toLowerCase()}
|
||||||
className={`${iconStyle} ${extraClass}`}
|
className={`${iconStyle} ${extraClass}`}
|
||||||
onClick={handleCommentClick}
|
onClick={handleCommentClick}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -379,14 +379,16 @@ const PostComponent = (props: Props): JSX.Element => {
|
|||||||
getHistory().push(`/${props.teamName}/pl/${post.id}`);
|
getHistory().push(`/${props.teamName}/pl/${post.id}`);
|
||||||
}, [props.isMobileView, props.actions, props.teamName, post?.id]);
|
}, [props.isMobileView, props.actions, props.teamName, post?.id]);
|
||||||
|
|
||||||
|
const {selectPostFromRightHandSideSearch} = props.actions;
|
||||||
|
|
||||||
const handleCommentClick = useCallback((e: React.MouseEvent) => {
|
const handleCommentClick = useCallback((e: React.MouseEvent) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
if (!post) {
|
if (!post) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
props.actions.selectPostFromRightHandSideSearch(post);
|
selectPostFromRightHandSideSearch(post);
|
||||||
}, [post, props.actions, props.actions.selectPostFromRightHandSideSearch]);
|
}, [post, selectPostFromRightHandSideSearch]);
|
||||||
|
|
||||||
const handleThreadClick = useCallback((e: React.MouseEvent) => {
|
const handleThreadClick = useCallback((e: React.MouseEvent) => {
|
||||||
if (props.currentTeam?.id === teamId) {
|
if (props.currentTeam?.id === teamId) {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// See LICENSE.txt for license information.
|
// See LICENSE.txt for license information.
|
||||||
|
|
||||||
import classnames from 'classnames';
|
import classnames from 'classnames';
|
||||||
import React, {useEffect, useRef, useState} from 'react';
|
import React, {useCallback, useEffect, useRef, useState} from 'react';
|
||||||
import type {ReactNode} from 'react';
|
import type {ReactNode} from 'react';
|
||||||
import {FormattedMessage} from 'react-intl';
|
import {FormattedMessage} from 'react-intl';
|
||||||
|
|
||||||
@@ -65,6 +65,11 @@ const PostOptions = (props: Props): JSX.Element => {
|
|||||||
const [showDotMenu, setShowDotMenu] = useState(false);
|
const [showDotMenu, setShowDotMenu] = useState(false);
|
||||||
const [showActionsMenu, setShowActionsMenu] = useState(false);
|
const [showActionsMenu, setShowActionsMenu] = useState(false);
|
||||||
|
|
||||||
|
const toggleEmojiPicker = useCallback(() => {
|
||||||
|
setShowEmojiPicker(!showEmojiPicker);
|
||||||
|
props.handleDropdownOpened!(!showEmojiPicker);
|
||||||
|
}, [props.handleDropdownOpened, showEmojiPicker]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const locationToUse = props.location === 'RHS_COMMENT' ? Locations.RHS_ROOT : props.location;
|
const locationToUse = props.location === 'RHS_COMMENT' ? Locations.RHS_ROOT : props.location;
|
||||||
if (props.isLastPost &&
|
if (props.isLastPost &&
|
||||||
@@ -73,7 +78,8 @@ const PostOptions = (props: Props): JSX.Element => {
|
|||||||
toggleEmojiPicker();
|
toggleEmojiPicker();
|
||||||
props.actions.emitShortcutReactToLastPostFrom(Locations.NO_WHERE);
|
props.actions.emitShortcutReactToLastPostFrom(Locations.NO_WHERE);
|
||||||
}
|
}
|
||||||
}, [props.isLastPost, props.shortcutReactToLastPostEmittedFrom]);
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [props.isLastPost, props.shortcutReactToLastPostEmittedFrom, props.location, props.isPostHeaderVisible]);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
channelIsArchived,
|
channelIsArchived,
|
||||||
@@ -92,11 +98,6 @@ const PostOptions = (props: Props): JSX.Element => {
|
|||||||
props.removePost(props.post);
|
props.removePost(props.post);
|
||||||
}
|
}
|
||||||
|
|
||||||
const toggleEmojiPicker = () => {
|
|
||||||
setShowEmojiPicker(!showEmojiPicker);
|
|
||||||
props.handleDropdownOpened!(!showEmojiPicker);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleDotMenuOpened = (open: boolean) => {
|
const handleDotMenuOpened = (open: boolean) => {
|
||||||
setShowDotMenu(open);
|
setShowDotMenu(open);
|
||||||
props.handleDropdownOpened!(open);
|
props.handleDropdownOpened!(open);
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ const RhsThread = ({
|
|||||||
// if team-scoped and mismatched team, close rhs
|
// if team-scoped and mismatched team, close rhs
|
||||||
dispatch(closeRightHandSide());
|
dispatch(closeRightHandSide());
|
||||||
}
|
}
|
||||||
}, [currentTeam, channel]);
|
}, [currentTeam, channel, dispatch]);
|
||||||
|
|
||||||
if (selected == null || !channel) {
|
if (selected == null || !channel) {
|
||||||
return (
|
return (
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user