1
0
Fork 0
forked from Mirrors/gomuks

web/timeline/menu: don't allow context menu to overflow to the left

This commit is contained in:
Tulir Asokan 2024-12-15 19:11:48 +02:00
parent 7b7fbce4df
commit b36b7b4e9d

View file

@ -36,8 +36,14 @@ export const getEncryption = (room: RoomStateStore): boolean =>{
return encryptionEvent?.content?.algorithm === "m.megolm.v1.aes-sha2"
}
export function getModalStyleFromMouse(evt: React.MouseEvent, modalHeight: number): CSSProperties {
export function getModalStyleFromMouse(
evt: React.MouseEvent, modalHeight: number, modalWidth = 10 * 16,
): CSSProperties {
const style: CSSProperties = { right: window.innerWidth - evt.clientX }
if (evt.clientX - modalWidth < 4) {
delete style.right
style.left = "4px"
}
if (evt.clientY + modalHeight > window.innerHeight) {
style.bottom = window.innerHeight - evt.clientY
} else {