From abd15f6df2623206d6aefce746027bb7d9ffdddf Mon Sep 17 00:00:00 2001 From: Ayush Chauhan Date: Tue, 24 Dec 2024 01:34:47 +0530 Subject: [PATCH 1/2] MM-61641: Update post options to use semantic list elements --- .../src/components/post/post_options.tsx | 49 ++++++++++++------- .../post_view/post_reaction/post_reaction.tsx | 2 +- .../post_recent_reactions.tsx | 4 +- .../src/sass/components/_post-menu.scss | 1 + 4 files changed, 36 insertions(+), 20 deletions(-) diff --git a/webapp/channels/src/components/post/post_options.tsx b/webapp/channels/src/components/post/post_options.tsx index 25eec3bfc31f..2782056b57a3 100644 --- a/webapp/channels/src/components/post/post_options.tsx +++ b/webapp/channels/src/components/post/post_options.tsx @@ -59,7 +59,7 @@ type Props = { }; const PostOptions = (props: Props): JSX.Element => { - const dotMenuRef = useRef(null); + const dotMenuRef = useRef(null); const [showEmojiPicker, setShowEmojiPicker] = useState(false); const [showDotMenu, setShowDotMenu] = useState(false); @@ -120,12 +120,14 @@ const PostOptions = (props: Props): JSX.Element => { let commentIcon; if (showCommentIcon) { commentIcon = ( +
  • + /> +
  • ); } @@ -144,7 +146,7 @@ const PostOptions = (props: Props): JSX.Element => { teamId={props.teamId} emojis={props.recentEmojis} size={showMoreReactions ? 3 : 1} - /> + /> ); } @@ -152,6 +154,7 @@ const PostOptions = (props: Props): JSX.Element => { let postReaction; if (showReactionIcon) { postReaction = ( +
  • { getDotMenuRef={getDotMenuRef} showEmojiPicker={showEmojiPicker} toggleEmojiPicker={toggleEmojiPicker} - /> + /> +
  • ); } let flagIcon: ReactNode = null; if (!isMobileView && (!isEphemeral && !post.failed && !systemMessage)) { flagIcon = ( - + + /> + ); } // Action menus const showActionsMenuIcon = props.shouldShowActionsMenu && (isMobileView || hoverLocal); const actionsMenu = showActionsMenuIcon && ( +
  • + /> +
  • ); let pluginItems: ReactNode = null; @@ -193,10 +201,11 @@ const PostOptions = (props: Props): JSX.Element => { if (item.component) { const Component = item.component as any; return ( +
  • + /> +
  • ); } return null; @@ -204,6 +213,7 @@ const PostOptions = (props: Props): JSX.Element => { } const dotMenu = ( +
  • { isReadOnly={isReadOnly || channelIsArchived} isMenuOpen={showDotMenu} enableEmojiPicker={props.enableEmojiPicker} - /> + /> +
  • ); // Build post options @@ -235,10 +246,11 @@ const PostOptions = (props: Props): JSX.Element => { } else if (props.location === Locations.SEARCH) { const hasCRTFooter = props.collapsedThreadsEnabled && !post.root_id && (post.reply_count > 0 || post.is_following); options = ( -
    +
      {dotMenu} {flagIcon} {props.canReply && !hasCRTFooter && +
    • { postId={post.id} searchStyle={'search-item__comment'} extraClass={props.replyCount ? 'icon--visible' : ''} - /> + /> +
    • } +
    • + > + /> -
    + + ); } else if (!props.isPostBeingEdited) { options = ( -
    { {actionsMenu} {commentIcon} {(collapsedThreadsEnabled || showRecentlyUsedReactions) && dotMenu} -
    + ); } diff --git a/webapp/channels/src/components/post_view/post_reaction/post_reaction.tsx b/webapp/channels/src/components/post_view/post_reaction/post_reaction.tsx index 06812ba73da6..354d7492ccc6 100644 --- a/webapp/channels/src/components/post_view/post_reaction/post_reaction.tsx +++ b/webapp/channels/src/components/post_view/post_reaction/post_reaction.tsx @@ -31,7 +31,7 @@ export type Props = WrappedComponentProps & { channelId?: string; postId: string; teamId: string; - getDotMenuRef: () => HTMLDivElement | null; + getDotMenuRef: () => HTMLUListElement | null; location?: keyof typeof Locations; showEmojiPicker: boolean; toggleEmojiPicker: (e?: React.MouseEvent) => void; diff --git a/webapp/channels/src/components/post_view/post_recent_reactions/post_recent_reactions.tsx b/webapp/channels/src/components/post_view/post_recent_reactions/post_recent_reactions.tsx index cb445b201dfe..a9f4f3495033 100644 --- a/webapp/channels/src/components/post_view/post_recent_reactions/post_recent_reactions.tsx +++ b/webapp/channels/src/components/post_view/post_recent_reactions/post_recent_reactions.tsx @@ -96,13 +96,13 @@ export default class PostRecentReactions extends React.PureComponent -
    +
  • -
  • + ), diff --git a/webapp/channels/src/sass/components/_post-menu.scss b/webapp/channels/src/sass/components/_post-menu.scss index f262a46f5979..0ee21f8f63af 100644 --- a/webapp/channels/src/sass/components/_post-menu.scss +++ b/webapp/channels/src/sass/components/_post-menu.scss @@ -12,6 +12,7 @@ border: 1px solid transparent; border-radius: 4px; white-space: normal; + list-style: none; } .post-menu__item { From 60a2389ad6f7974006dc6022ca24b3034a86e90b Mon Sep 17 00:00:00 2001 From: Ayush Chauhan Date: Tue, 24 Dec 2024 16:46:43 +0530 Subject: [PATCH 2/2] MM-61641: Fix lint --- .../src/components/post/post_options.tsx | 104 +++++++++--------- .../src/sass/components/_post-menu.scss | 2 +- 2 files changed, 53 insertions(+), 53 deletions(-) diff --git a/webapp/channels/src/components/post/post_options.tsx b/webapp/channels/src/components/post/post_options.tsx index 2782056b57a3..30aab83fe44e 100644 --- a/webapp/channels/src/components/post/post_options.tsx +++ b/webapp/channels/src/components/post/post_options.tsx @@ -120,12 +120,12 @@ const PostOptions = (props: Props): JSX.Element => { let commentIcon; if (showCommentIcon) { commentIcon = ( -
  • - +
  • ); @@ -146,7 +146,7 @@ const PostOptions = (props: Props): JSX.Element => { teamId={props.teamId} emojis={props.recentEmojis} size={showMoreReactions ? 3 : 1} - /> + /> ); } @@ -154,15 +154,15 @@ const PostOptions = (props: Props): JSX.Element => { let postReaction; if (showReactionIcon) { postReaction = ( -
  • - +
  • ); @@ -171,11 +171,11 @@ const PostOptions = (props: Props): JSX.Element => { let flagIcon: ReactNode = null; if (!isMobileView && (!isEphemeral && !post.failed && !systemMessage)) { flagIcon = ( -
  • - +
  • ); @@ -184,12 +184,12 @@ const PostOptions = (props: Props): JSX.Element => { // Action menus const showActionsMenuIcon = props.shouldShowActionsMenu && (isMobileView || hoverLocal); const actionsMenu = showActionsMenuIcon && ( -
  • - +
  • ); @@ -202,8 +202,8 @@ const PostOptions = (props: Props): JSX.Element => { const Component = item.component as any; return (
  • -
  • ); @@ -213,17 +213,17 @@ const PostOptions = (props: Props): JSX.Element => { } const dotMenu = ( -
  • - +
  • ); @@ -250,7 +250,7 @@ const PostOptions = (props: Props): JSX.Element => { {dotMenu} {flagIcon} {props.canReply && !hasCRTFooter && -
  • +
  • { postId={post.id} searchStyle={'search-item__comment'} extraClass={props.replyCount ? 'icon--visible' : ''} - /> -
  • + /> + } -
  • - + - - +
  • ); diff --git a/webapp/channels/src/sass/components/_post-menu.scss b/webapp/channels/src/sass/components/_post-menu.scss index 0ee21f8f63af..8e35f99b9533 100644 --- a/webapp/channels/src/sass/components/_post-menu.scss +++ b/webapp/channels/src/sass/components/_post-menu.scss @@ -11,8 +11,8 @@ padding: 4px; border: 1px solid transparent; border-radius: 4px; - white-space: normal; list-style: none; + white-space: normal; } .post-menu__item {