Skip to content

Commit 17660da

Browse files
fix: border of radio button & checkbox is not proper
1 parent 7584667 commit 17660da

File tree

3 files changed

+32
-77
lines changed

3 files changed

+32
-77
lines changed

apps/OpenSign/src/components/pdf/Placeholder.js

Lines changed: 29 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ function Placeholder(props) {
114114
props.pos?.options?.validation?.format
115115
)
116116
);
117+
const [getCheckboxRenderWidth, setGetCheckboxRenderWidth] = useState({
118+
width: null,
119+
height: null
120+
});
117121
const dateFormatArr = [
118122
"L",
119123
"DD-MM-YYYY",
@@ -125,6 +129,21 @@ function Placeholder(props) {
125129
"DD MMM, YYYY",
126130
"DD MMMM, YYYY"
127131
];
132+
133+
useEffect(() => {
134+
const updateWidth = () => {
135+
const rndElement = document.getElementById(props.pos.key);
136+
if (rndElement) {
137+
const { width, height } = rndElement.getBoundingClientRect();
138+
setGetCheckboxRenderWidth({ width: width, height: height });
139+
}
140+
};
141+
142+
// Delay to ensure rendering is complete
143+
const timer = setTimeout(updateWidth, 0);
144+
145+
return () => clearTimeout(timer);
146+
}, [props.pos]);
128147
//function change format array list with selected date and format
129148
const changeDateFormat = () => {
130149
const updateDate = [];
@@ -330,8 +349,8 @@ function Placeholder(props) {
330349
className="fa-solid fa-gear settingIcon"
331350
style={{
332351
color: "#188ae2",
333-
right: "9px",
334-
top: "-28px"
352+
right: "29px",
353+
top: "-19px"
335354
}}
336355
></i>
337356
) : (
@@ -351,19 +370,7 @@ function Placeholder(props) {
351370
handleOnClickSettingIcon();
352371
}}
353372
className="fa-solid fa-gear settingIcon"
354-
style={{
355-
color: "#188ae2",
356-
right: ["checkbox", radioButtonWidget].includes(
357-
props.pos.type
358-
)
359-
? "24px"
360-
: "47px",
361-
top: ["checkbox", radioButtonWidget].includes(
362-
props.pos.type
363-
)
364-
? "-28px"
365-
: "-19px"
366-
}}
373+
style={{ color: "#188ae2", right: "47px", top: "-19px" }}
367374
></i>
368375
)
369376
)}
@@ -382,19 +389,7 @@ function Placeholder(props) {
382389
props.handleLinkUser(props.data.Id);
383390
props.setUniqueId(props.data.Id);
384391
}}
385-
style={{
386-
color: "#188ae2",
387-
right:
388-
props.pos.type === "checkbox" ||
389-
props.pos.type === radioButtonWidget
390-
? "8px"
391-
: "32px",
392-
top:
393-
props.pos.type === "checkbox" ||
394-
props.pos.type === radioButtonWidget
395-
? "-28px"
396-
: "-18px"
397-
}}
392+
style={{ color: "#188ae2", right: "32px", top: "-18px" }}
398393
></i>
399394
)}
400395
</>
@@ -472,19 +467,7 @@ function Placeholder(props) {
472467
className="fa-regular fa-copy signCopy"
473468
onClick={(e) => handleCopyPlaceholder(e)}
474469
onTouchEnd={(e) => handleCopyPlaceholder(e)}
475-
style={{
476-
color: "#188ae2",
477-
right:
478-
props.pos.type === "checkbox" ||
479-
props.pos.type === radioButtonWidget
480-
? "-9px"
481-
: "12px",
482-
top:
483-
props.pos.type === "checkbox" ||
484-
props.pos.type === radioButtonWidget
485-
? "-28px"
486-
: "-18px"
487-
}}
470+
style={{ color: "#188ae2", right: "12px", top: "-18px" }}
488471
></i>
489472
<i
490473
className="fa-regular fa-circle-xmark signCloseBtn"
@@ -507,19 +490,7 @@ function Placeholder(props) {
507490
props.setIsStamp(false);
508491
}
509492
}}
510-
style={{
511-
color: "#188ae2",
512-
right:
513-
props.pos.type === "checkbox" ||
514-
props.pos.type === radioButtonWidget
515-
? "-27px"
516-
: "-8px",
517-
top:
518-
props.pos.type === "checkbox" ||
519-
props.pos.type === radioButtonWidget
520-
? "-28px"
521-
: "-18px"
522-
}}
493+
style={{ color: "#188ae2", right: "-8px", top: "-18px" }}
523494
></i>
524495
</>
525496
)
@@ -528,6 +499,7 @@ function Placeholder(props) {
528499

529500
return (
530501
<Rnd
502+
id={props.pos.key}
531503
data-tut={props.pos.key === props.unSignedWidgetId ? "IsSigned" : ""}
532504
key={props.pos.key}
533505
lockAspectRatio={
@@ -637,20 +609,7 @@ function Placeholder(props) {
637609
props.pos.type !== radioButtonWidget &&
638610
props.pos.type !== "checkbox" &&
639611
props.pos.key === props.selectWidgetId ? (
640-
<BorderResize
641-
right={
642-
props.pos.type === "checkbox" ||
643-
props.pos.type === radioButtonWidget
644-
? -21
645-
: -12
646-
}
647-
top={
648-
props.pos.type === "checkbox" ||
649-
props.pos.type === radioButtonWidget
650-
? -21
651-
: -11
652-
}
653-
/>
612+
<BorderResize right={-12} top={-11} />
654613
) : props.data && props.isNeedSign && props.pos.type !== "checkbox" ? (
655614
props.data?.signerObjId === props.signerObjId &&
656615
props.pos.type !== radioButtonWidget &&
@@ -670,14 +629,15 @@ function Placeholder(props) {
670629
setDraggingEnabled={setDraggingEnabled}
671630
pos={props.pos}
672631
isPlaceholder={props.isPlaceholder}
632+
getCheckboxRenderWidth={getCheckboxRenderWidth}
673633
/>
674634
)}
675635
{isMobile ? (
676636
<div
677637
style={{
678638
left: props.xPos(props.pos, props.isSignYourself),
679639
top: props.yPos(props.pos, props.isSignYourself),
680-
width: props.posWidth(props.pos, props.isSignYourself),
640+
width: "auto", //props.posWidth(props.pos, props.isSignYourself),
681641
// height: props.posHeight(props.pos, props.isSignYourself),
682642
zIndex: "10"
683643
}}

apps/OpenSign/src/components/pdf/PlaceholderBorder.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,13 @@ import {
66
resizeBorderExtraWidth
77
} from "../../constant/Utils";
88
function PlaceholderBorder(props) {
9-
const getResizeBorderExtraWidth =
10-
props.pos.type === "checkbox" || props.pos.type === radioButtonWidget
11-
? 38
12-
: resizeBorderExtraWidth();
9+
const getResizeBorderExtraWidth = resizeBorderExtraWidth();
1310
const defaultWidth = defaultWidthHeight(props.pos.type).width;
1411
const defaultHeight = defaultWidthHeight(props.pos.type).height;
1512

1613
const handleMinWidth = () => {
1714
if (props.pos.type === "checkbox" || props.pos.type === radioButtonWidget) {
18-
return "120%";
15+
return props.getCheckboxRenderWidth.width + getResizeBorderExtraWidth;
1916
} else {
2017
return props.pos.Width
2118
? props.pos.Width + getResizeBorderExtraWidth
@@ -24,7 +21,7 @@ function PlaceholderBorder(props) {
2421
};
2522
const handleMinHeight = () => {
2623
if (props.pos.type === "checkbox" || props.pos.type === radioButtonWidget) {
27-
return "120%";
24+
return props.getCheckboxRenderWidth.height + getResizeBorderExtraWidth;
2825
} else {
2926
return props.pos.Height
3027
? props.pos.Height + getResizeBorderExtraWidth

apps/OpenSign/src/styles/signature.css

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,8 +339,6 @@
339339
display: flex !important;
340340
justify-content: center !important;
341341
align-items: center !important;
342-
min-width:max-content;
343-
min-height: max-content;
344342
}
345343

346344
.finishBtn {

0 commit comments

Comments
 (0)