Skip to content

Commit

Permalink
Make triple dot menu work on really small screen widths
Browse files Browse the repository at this point in the history
  • Loading branch information
josh-signal committed Oct 5, 2021
1 parent 48aaf9e commit 87ea957
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 17 deletions.
15 changes: 15 additions & 0 deletions stylesheets/_modules.scss
Expand Up @@ -262,6 +262,21 @@
);
}
}

&--container {
border-radius: 4px;
height: 24px;
// the z-index here is so that this container is above the message and when
// clicked on, doesn't propagate the click event to the message.
z-index: 2;

@include light-theme {
background-color: $color-white;
}
@include dark-theme {
background-color: $color-gray-95;
}
}
}

.module-message__buttons__menu--incoming {
Expand Down
6 changes: 5 additions & 1 deletion ts/components/StopPropagation.tsx
Expand Up @@ -6,10 +6,14 @@ import React, { ReactNode } from 'react';
// Whenever you don't want click events to propagate into their parent container
export const StopPropagation = ({
children,
className,
}: {
children: ReactNode;
className?: string;
}): JSX.Element => (
// eslint-disable-next-line max-len
// eslint-disable-next-line jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events
<div onClick={ev => ev.stopPropagation()}>{children}</div>
<div className={className} onClick={ev => ev.stopPropagation()}>
{children}
</div>
);
34 changes: 18 additions & 16 deletions ts/components/conversation/Message.tsx
Expand Up @@ -1407,22 +1407,24 @@ export class Message extends React.PureComponent<Props, State> {
const maybePopperRef = !isWide ? popperRef : undefined;

return (
<ContextMenuTrigger
id={triggerId}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
ref={this.captureMenuTrigger as any}
>
<div
ref={maybePopperRef}
role="button"
onClick={this.showMenu}
aria-label={i18n('messageContextMenuButton')}
className={classNames(
'module-message__buttons__menu',
`module-message__buttons__download--${direction}`
)}
/>
</ContextMenuTrigger>
<StopPropagation className="module-message__buttons__menu--container">
<ContextMenuTrigger
id={triggerId}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
ref={this.captureMenuTrigger as any}
>
<div
ref={maybePopperRef}
role="button"
onClick={this.showMenu}
aria-label={i18n('messageContextMenuButton')}
className={classNames(
'module-message__buttons__menu',
`module-message__buttons__download--${direction}`
)}
/>
</ContextMenuTrigger>
</StopPropagation>
);
}}
</Reference>
Expand Down

0 comments on commit 87ea957

Please sign in to comment.