fix(create): remove small drawn fields
All checks were successful
Open PR on Staging / audit_and_check (pull_request) Successful in 38s

Closes #234
This commit is contained in:
enes 2024-11-29 12:17:23 +01:00
parent 413da78c5c
commit 902ad73faf

View File

@ -22,6 +22,11 @@ import { AvatarIconButton } from '../UserAvatarIconButton'
import { UserAvatar } from '../UserAvatar' import { UserAvatar } from '../UserAvatar'
import _ from 'lodash' import _ from 'lodash'
const MINIMUM_RECT_SIZE = {
width: 21,
height: 21
} as const
const DEFAULT_START_SIZE = { const DEFAULT_START_SIZE = {
width: 140, width: 140,
height: 40 height: 40
@ -91,6 +96,7 @@ export const DrawPDFFields = (props: Props) => {
window.removeEventListener('pointerup', handlePointerUp) window.removeEventListener('pointerup', handlePointerUp)
window.removeEventListener('pointercancel', handlePointerUp) window.removeEventListener('pointercancel', handlePointerUp)
} }
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []) }, [])
const refreshPdfFiles = () => { const refreshPdfFiles = () => {
@ -149,6 +155,18 @@ export const DrawPDFFields = (props: Props) => {
* @param event Pointer event * @param event Pointer event
*/ */
const handlePointerUp = () => { const handlePointerUp = () => {
sigitFiles.forEach((s) => {
s.pages?.forEach((p) => {
// Remove small rects (accidentaly created)
p.drawnFields = p.drawnFields.filter(
(f) =>
!(
f.width < MINIMUM_RECT_SIZE.width ||
f.height < MINIMUM_RECT_SIZE.height
)
)
})
})
setMouseState((prev) => { setMouseState((prev) => {
return { return {
...prev, ...prev,
@ -157,6 +175,7 @@ export const DrawPDFFields = (props: Props) => {
resizing: false resizing: false
} }
}) })
refreshPdfFiles()
} }
/** /**