Position sticker picker correctly
This commit is contained in:
parent
31b3b2e2ed
commit
9018973f15
2 changed files with 13 additions and 11 deletions
|
@ -33,7 +33,6 @@ import {
|
||||||
ContextMenuTooltipButton,
|
ContextMenuTooltipButton,
|
||||||
useContextMenu,
|
useContextMenu,
|
||||||
MenuItem,
|
MenuItem,
|
||||||
alwaysAboveRightOf,
|
|
||||||
} from "../../structures/ContextMenu";
|
} from "../../structures/ContextMenu";
|
||||||
import AccessibleTooltipButton from "../elements/AccessibleTooltipButton";
|
import AccessibleTooltipButton from "../elements/AccessibleTooltipButton";
|
||||||
import ReplyPreview from "./ReplyPreview";
|
import ReplyPreview from "./ReplyPreview";
|
||||||
|
@ -407,15 +406,9 @@ export default class MessageComposer extends React.Component<IProps, IState> {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
private renderButtons(): JSX.Element | JSX.Element[] {
|
private renderButtons(menuPosition): JSX.Element | JSX.Element[] {
|
||||||
const buttons = [];
|
const buttons = [];
|
||||||
|
|
||||||
let menuPosition;
|
|
||||||
if (this.ref.current) {
|
|
||||||
const contentRect = this.ref.current.getBoundingClientRect();
|
|
||||||
menuPosition = alwaysAboveRightOf(contentRect);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!this.state.haveRecording) {
|
if (!this.state.haveRecording) {
|
||||||
buttons.push(
|
buttons.push(
|
||||||
<UploadButton key="controls_upload" roomId={this.props.room.roomId} />,
|
<UploadButton key="controls_upload" roomId={this.props.room.roomId} />,
|
||||||
|
@ -466,7 +459,7 @@ export default class MessageComposer extends React.Component<IProps, IState> {
|
||||||
menuWidth={50}
|
menuWidth={50}
|
||||||
>
|
>
|
||||||
{ buttons.slice(1).map((button, index) => (
|
{ buttons.slice(1).map((button, index) => (
|
||||||
<MenuItem className="mx_CallContextMenu_item" key={index} onClick={() => setTimeout(this.toggleButtonMenu, 500)}>
|
<MenuItem className="mx_CallContextMenu_item" key={index} onClick={this.toggleButtonMenu}>
|
||||||
{ button }
|
{ button }
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
)) }
|
)) }
|
||||||
|
@ -484,6 +477,12 @@ export default class MessageComposer extends React.Component<IProps, IState> {
|
||||||
null,
|
null,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
let menuPosition;
|
||||||
|
if (this.ref.current) {
|
||||||
|
const contentRect = this.ref.current.getBoundingClientRect();
|
||||||
|
menuPosition = aboveLeftOf(contentRect);
|
||||||
|
}
|
||||||
|
|
||||||
if (!this.state.tombstone && this.state.canSendMessages) {
|
if (!this.state.tombstone && this.state.canSendMessages) {
|
||||||
controls.push(
|
controls.push(
|
||||||
<SendMessageComposer
|
<SendMessageComposer
|
||||||
|
@ -547,7 +546,8 @@ export default class MessageComposer extends React.Component<IProps, IState> {
|
||||||
<Stickerpicker
|
<Stickerpicker
|
||||||
room={this.props.room}
|
room={this.props.room}
|
||||||
showStickers={this.state.showStickers}
|
showStickers={this.state.showStickers}
|
||||||
setShowStickers={this.showStickers} />,
|
setShowStickers={this.showStickers}
|
||||||
|
menuPosition={menuPosition} />,
|
||||||
);
|
);
|
||||||
|
|
||||||
const showSendButton = !this.state.isComposerEmpty || this.state.haveRecording;
|
const showSendButton = !this.state.isComposerEmpty || this.state.haveRecording;
|
||||||
|
@ -559,7 +559,7 @@ export default class MessageComposer extends React.Component<IProps, IState> {
|
||||||
<ReplyPreview permalinkCreator={this.props.permalinkCreator} />
|
<ReplyPreview permalinkCreator={this.props.permalinkCreator} />
|
||||||
<div className="mx_MessageComposer_row">
|
<div className="mx_MessageComposer_row">
|
||||||
{ controls }
|
{ controls }
|
||||||
{ this.renderButtons() }
|
{ this.renderButtons(menuPosition) }
|
||||||
{ showSendButton && (
|
{ showSendButton && (
|
||||||
<SendButton
|
<SendButton
|
||||||
key="controls_send"
|
key="controls_send"
|
||||||
|
|
|
@ -43,6 +43,7 @@ const PERSISTED_ELEMENT_KEY = "stickerPicker";
|
||||||
interface IProps {
|
interface IProps {
|
||||||
room: Room;
|
room: Room;
|
||||||
showStickers: boolean;
|
showStickers: boolean;
|
||||||
|
menuPosition?: any;
|
||||||
setShowStickers: (showStickers: boolean) => void;
|
setShowStickers: (showStickers: boolean) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -407,6 +408,7 @@ export default class Stickerpicker extends React.PureComponent<IProps, IState> {
|
||||||
menuPaddingLeft={0}
|
menuPaddingLeft={0}
|
||||||
menuPaddingRight={0}
|
menuPaddingRight={0}
|
||||||
zIndex={STICKERPICKER_Z_INDEX}
|
zIndex={STICKERPICKER_Z_INDEX}
|
||||||
|
{...this.props.menuPosition}
|
||||||
>
|
>
|
||||||
<GenericElementContextMenu element={this.getStickerpickerContent()} onResize={this.onFinished} />
|
<GenericElementContextMenu element={this.getStickerpickerContent()} onResize={this.onFinished} />
|
||||||
</ContextMenu>;
|
</ContextMenu>;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue