From c7a21360ee7f5bce8dc621273e2a98308ed9ad0d Mon Sep 17 00:00:00 2001 From: Eduard Kuzmenko Date: Thu, 12 Nov 2020 01:20:32 +0200 Subject: [PATCH] Fix following by bubble beside button on mobiles --- src/components/chat/contextMenu.ts | 2 +- src/components/misc.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/chat/contextMenu.ts b/src/components/chat/contextMenu.ts index 1f9bd499..40b8f60c 100644 --- a/src/components/chat/contextMenu.ts +++ b/src/components/chat/contextMenu.ts @@ -80,7 +80,7 @@ export default class ChatContextMenu { const className = (e.target as HTMLElement).className; if(!className || !className.includes) return; - const good = ['bubble', 'bubble__container', 'message', 'time', 'inner'].find(c => className.includes(c)); + const good = ['bubble', 'bubble__container', 'message', 'time', 'inner'].find(c => className.match(new RegExp(c + '($|\\s)'))); if(good) { onContextMenu(e); } diff --git a/src/components/misc.ts b/src/components/misc.ts index ffd9a57a..cae2d116 100644 --- a/src/components/misc.ts +++ b/src/components/misc.ts @@ -228,6 +228,7 @@ export function positionMenu({clientX, clientY}: {clientX: number, clientY: numb } // ! don't need reverse for this, this will be the side WHERE ANIMATION WILL END ! + // ! NO LOGIC HERE ! let verticalSide: 'top' | 'bottom'; if(side !== undefined) { @@ -251,7 +252,7 @@ export function positionMenu({clientX, clientY}: {clientX: number, clientY: numb } if((clientY + scrollHeight + PADDING_TOP) > innerHeight) { - elem.style.top = Math.max(PADDING_TOP, clientY - scrollHeight) + 'px'; + elem.style.top = clamp(clientY - scrollHeight, PADDING_TOP, innerHeight - scrollHeight - PADDING_TOP) + 'px'; // elem.style.top = (innerHeight - scrollHeight - PADDING_TOP) + 'px'; verticalSide = 'top'; } else {