Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 9c4b258

Browse files
author
Weblate
committed
Merge remote-tracking branch 'origin/develop' into develop
2 parents 4ce6093 + 7588d43 commit 9c4b258

File tree

1 file changed

+32
-6
lines changed

1 file changed

+32
-6
lines changed

src/components/views/rooms/Stickerpicker.js

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,19 @@ export default class Stickerpicker extends React.Component {
127127
}
128128

129129
_onWidgetAction(payload) {
130-
if (payload.action === "user_widget_updated") {
131-
this.forceUpdate();
132-
} else if (payload.action === "stickerpicker_close") {
133-
this.setState({showStickers: false});
130+
switch (payload.action) {
131+
case "user_widget_updated":
132+
this.forceUpdate();
133+
break;
134+
case "stickerpicker_close":
135+
this.setState({showStickers: false});
136+
break;
137+
case "show_right_panel":
138+
case "hide_right_panel":
139+
case "show_left_panel":
140+
case "hide_left_panel":
141+
this.setState({showStickers: false});
142+
break;
134143
}
135144
}
136145

@@ -244,16 +253,33 @@ export default class Stickerpicker extends React.Component {
244253
* @param {Event} e Event that triggered the function
245254
*/
246255
_onShowStickersClick(e) {
256+
// XXX: Simplify by using a context menu that is positioned relative to the sticker picker button
257+
247258
const buttonRect = e.target.getBoundingClientRect();
248259

249260
// The window X and Y offsets are to adjust position when zoomed in to page
250-
const x = buttonRect.right + window.pageXOffset - 42;
261+
let x = buttonRect.right + window.pageXOffset - 41;
262+
263+
// Amount of horizontal space between the right of menu and the right of the viewport
264+
// (10 = amount needed to make chevron centrally aligned)
265+
const rightPad = 10;
266+
267+
// When the sticker picker would be displayed off of the viewport, adjust x
268+
// (302 = width of context menu, including borders)
269+
x = Math.min(x, document.body.clientWidth - (302 + rightPad));
270+
271+
// Offset the chevron location, which is relative to the left of the context menu
272+
// (10 = offset when context menu would not be displayed off viewport)
273+
// (8 = value required in practice (possibly 10 - 2 where the 2 = context menu borders)
274+
const stickerPickerChevronOffset = Math.max(10, 8 + window.pageXOffset + buttonRect.left - x);
275+
251276
const y = (buttonRect.top + (buttonRect.height / 2) + window.pageYOffset) - 19;
252277

253278
this.setState({
254279
showStickers: true,
255280
stickerPickerX: x,
256281
stickerPickerY: y,
282+
stickerPickerChevronOffset,
257283
});
258284
}
259285

@@ -306,7 +332,7 @@ export default class Stickerpicker extends React.Component {
306332

307333
const stickerPicker = <ContextualMenu
308334
elementClass={GenericElementContextMenu}
309-
chevronOffset={10}
335+
chevronOffset={this.state.stickerPickerChevronOffset}
310336
chevronFace={'bottom'}
311337
left={this.state.stickerPickerX}
312338
top={this.state.stickerPickerY}

0 commit comments

Comments
 (0)