Make triple dot menu work on really small screen widths

This commit is contained in:
Josh Perez 2021-10-05 09:58:34 -04:00 committed by GitHub
parent 48aaf9e4f3
commit 87ea95735e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 38 additions and 17 deletions

View file

@ -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 { .module-message__buttons__menu--incoming {

View file

@ -6,10 +6,14 @@ import React, { ReactNode } from 'react';
// Whenever you don't want click events to propagate into their parent container // Whenever you don't want click events to propagate into their parent container
export const StopPropagation = ({ export const StopPropagation = ({
children, children,
className,
}: { }: {
children: ReactNode; children: ReactNode;
className?: string;
}): JSX.Element => ( }): JSX.Element => (
// eslint-disable-next-line max-len // eslint-disable-next-line max-len
// eslint-disable-next-line jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events // 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>
); );

View file

@ -1407,22 +1407,24 @@ export class Message extends React.PureComponent<Props, State> {
const maybePopperRef = !isWide ? popperRef : undefined; const maybePopperRef = !isWide ? popperRef : undefined;
return ( return (
<ContextMenuTrigger <StopPropagation className="module-message__buttons__menu--container">
id={triggerId} <ContextMenuTrigger
// eslint-disable-next-line @typescript-eslint/no-explicit-any id={triggerId}
ref={this.captureMenuTrigger as any} // eslint-disable-next-line @typescript-eslint/no-explicit-any
> ref={this.captureMenuTrigger as any}
<div >
ref={maybePopperRef} <div
role="button" ref={maybePopperRef}
onClick={this.showMenu} role="button"
aria-label={i18n('messageContextMenuButton')} onClick={this.showMenu}
className={classNames( aria-label={i18n('messageContextMenuButton')}
'module-message__buttons__menu', className={classNames(
`module-message__buttons__download--${direction}` 'module-message__buttons__menu',
)} `module-message__buttons__download--${direction}`
/> )}
</ContextMenuTrigger> />
</ContextMenuTrigger>
</StopPropagation>
); );
}} }}
</Reference> </Reference>