From 2f5418462584ac5426c717680590d9156801ec57 Mon Sep 17 00:00:00 2001 From: enes Date: Fri, 23 Aug 2024 10:09:29 +0200 Subject: [PATCH] fix(drawing): clamp DrawField within img Closes #154 --- src/components/DrawPDFFields/index.tsx | 9 +++++++-- src/components/DrawPDFFields/style.module.scss | 1 - 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/components/DrawPDFFields/index.tsx b/src/components/DrawPDFFields/index.tsx index b720dad..e5e33ca 100644 --- a/src/components/DrawPDFFields/index.tsx +++ b/src/components/DrawPDFFields/index.tsx @@ -328,8 +328,10 @@ export const DrawPDFFields = (props: Props) => { ) => { const target = customTarget ? customTarget : event.currentTarget const rect = target.getBoundingClientRect() - const mouseX = event.clientX - rect.left //x position within the element. - const mouseY = event.clientY - rect.top //y position within the element. + + // Clamp X Y within the target + const mouseX = Math.min(event.clientX, rect.right) - rect.left //x position within the element. + const mouseY = Math.min(event.clientY, rect.bottom) - rect.top //y position within the element. return { mouseX, @@ -415,6 +417,9 @@ export const DrawPDFFields = (props: Props) => { }} labelId="counterparts" label="Counterparts" + sx={{ + background: 'white' + }} > {users .filter((u) => u.role === UserRole.signer) diff --git a/src/components/DrawPDFFields/style.module.scss b/src/components/DrawPDFFields/style.module.scss index 83844ce..b3150b3 100644 --- a/src/components/DrawPDFFields/style.module.scss +++ b/src/components/DrawPDFFields/style.module.scss @@ -75,7 +75,6 @@ bottom: -60px; min-width: 170px; min-height: 30px; - background: #fff; padding: 5px 0; } } -- 2.34.1