Merge pull request #5526 from matrix-org/t3chguy/fix/15832

Fix avatar upload prompt/tooltip floating wrong and permissions
This commit is contained in:
Michael Telatynski 2021-01-11 16:48:17 +00:00 committed by GitHub
commit 1c3adbc545
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 6 deletions

View file

@ -18,6 +18,16 @@ limitations under the License.
position: relative; position: relative;
width: min-content; width: min-content;
// this isn't a floating tooltip so override some things to not need to bother with z-index and floating
.mx_Tooltip {
display: inline-block;
position: absolute;
z-index: unset;
width: max-content;
left: 72px;
top: 0;
}
&::before, &::after { &::before, &::after {
content: ''; content: '';
position: absolute; position: absolute;

View file

@ -15,14 +15,15 @@ limitations under the License.
*/ */
import React, {useContext, useRef, useState} from 'react'; import React, {useContext, useRef, useState} from 'react';
import {EventType} from 'matrix-js-sdk/src/@types/event';
import classNames from 'classnames'; import classNames from 'classnames';
import AccessibleButton from "./AccessibleButton"; import AccessibleButton from "./AccessibleButton";
import Tooltip from './Tooltip';
import MatrixClientContext from "../../../contexts/MatrixClientContext"; import MatrixClientContext from "../../../contexts/MatrixClientContext";
import {useTimeout} from "../../../hooks/useTimeout"; import {useTimeout} from "../../../hooks/useTimeout";
import Analytics from "../../../Analytics"; import Analytics from "../../../Analytics";
import CountlyAnalytics from '../../../CountlyAnalytics'; import CountlyAnalytics from '../../../CountlyAnalytics';
import RoomContext from "../../../contexts/RoomContext";
export const AVATAR_SIZE = 52; export const AVATAR_SIZE = 52;
@ -50,6 +51,11 @@ const MiniAvatarUploader: React.FC<IProps> = ({ hasAvatar, hasAvatarLabel, noAva
const label = (hasAvatar || busy) ? hasAvatarLabel : noAvatarLabel; const label = (hasAvatar || busy) ? hasAvatarLabel : noAvatarLabel;
const {room} = useContext(RoomContext);
const canSetAvatar = room?.currentState.maySendStateEvent(EventType.RoomAvatar, cli.getUserId());
if (!canSetAvatar) return <React.Fragment>{ children }</React.Fragment>;
const visible = !!label && (hover || show);
return <React.Fragment> return <React.Fragment>
<input <input
type="file" type="file"
@ -82,11 +88,13 @@ const MiniAvatarUploader: React.FC<IProps> = ({ hasAvatar, hasAvatarLabel, noAva
> >
{ children } { children }
<Tooltip <div className={classNames("mx_Tooltip", {
label={label} "mx_Tooltip_visible": visible,
visible={!!label && (hover || show)} "mx_Tooltip_invisible": !visible,
forceOnRight })}>
/> <div className="mx_Tooltip_chevron" />
{ label }
</div>
</AccessibleButton> </AccessibleButton>
</React.Fragment>; </React.Fragment>;
}; };