From a672aa5be5f2aaff306cc28b04f3eec5c59c8660 Mon Sep 17 00:00:00 2001 From: ayush-chauhan233 Date: Tue, 28 Jan 2025 21:07:18 +0530 Subject: [PATCH] [MM-61641]: Ensure implicit list markup is avoided (#29787) * MM-61641: Update post options to use semantic list elements * MM-61641: Fix lint * Apply suggestions from code review --------- Co-authored-by: Mattermost Build Co-authored-by: Harrison Healey --- .../src/components/post/post_options.tsx | 127 ++++++++++-------- .../post_view/post_reaction/post_reaction.tsx | 2 +- .../post_recent_reactions.tsx | 4 +- .../src/sass/components/_post-menu.scss | 1 + 4 files changed, 75 insertions(+), 59 deletions(-) diff --git a/webapp/channels/src/components/post/post_options.tsx b/webapp/channels/src/components/post/post_options.tsx index 86b56a13af..d761e635a5 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 = ( - +
  • + +
  • ); } @@ -152,38 +154,44 @@ const PostOptions = (props: Props): JSX.Element => { let postReaction; if (showReactionIcon) { postReaction = ( - +
  • + +
  • ); } 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; return ( - +
  • + +
  • ); } return null; @@ -204,17 +213,19 @@ const PostOptions = (props: Props): JSX.Element => { } const dotMenu = ( - +
  • + +
  • ); // 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 && +
    • { 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 06812ba73d..354d7492cc 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 cb445b201d..a9f4f34950 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 f262a46f59..8e35f99b95 100644 --- a/webapp/channels/src/sass/components/_post-menu.scss +++ b/webapp/channels/src/sass/components/_post-menu.scss @@ -11,6 +11,7 @@ padding: 4px; border: 1px solid transparent; border-radius: 4px; + list-style: none; white-space: normal; }