Skip to content

Commit b4d65ef

Browse files
authored
Merge pull request #27 from Coding-Nonny/fixing-scroll-issue
made the form modal scrollable for forms that exceed scrollheight
2 parents fb88399 + 6f31222 commit b4d65ef

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

components/forms/Extrafields.tsx

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ function MultipleGroupFields<T>({
4747
const [editIndex, setEditIndex] = useState<number | null>(null);
4848
const [isModalOpen, setIsModalOpen] = useState(false);
4949

50-
5150
useEffect(() => {
5251
setGroupData(defaultValues);
5352
}, [defaultValues]);
@@ -151,6 +150,7 @@ function MultipleGroupFields<T>({
151150
name={field.name}
152151
onChange={handleInputChange}
153152
value={value}
153+
title="select"
154154
className={`w-full p-2 border rounded text-black ${isRequired}`}
155155
>
156156
<option value="">{field.placeholder}</option>
@@ -185,6 +185,23 @@ function MultipleGroupFields<T>({
185185
}
186186
};
187187

188+
// const parseStyle = (cssString: string): Record<string, string> =>
189+
// cssString
190+
// .split(";")
191+
// .filter(Boolean)
192+
// .reduce((acc, rule) => {
193+
// const [key, value] = rule.split(":").map((str) => str.trim());
194+
// if (key && value) {
195+
// acc[key.replace(/-([a-z])/g, (_, char) => char.toUpperCase())] =
196+
// value;
197+
// }
198+
// return acc;
199+
// }, {} as Record<string, string>);
200+
201+
// const styleString =
202+
// "position: fixed;display: flex;justify-content: center;width: 100%;height: 100%;background: rgba(0, 0, 0, 0.7);overflow:scroll;z-index: 1000;";
203+
// const styleObject = parseStyle(styleString);
204+
188205
return (
189206
<div className="flex flex-col items-center justify-center space-y-4 w-full">
190207
{errors.length > 0 && !onErrors && (
@@ -196,7 +213,7 @@ function MultipleGroupFields<T>({
196213
)}
197214

198215
{isModalOpen && (
199-
<div className="grid place-items-center fixed inset-0 w-svw h-svh bg-light-gray-opacity-2 py-4 z-30">
216+
<div className="fixed flex flex-row justify-center overflow-scroll inset-0 w-full h-full bg-light-gray-opacity-2 py-4 z-50">
200217
<div className="px-10 py-12 bg-deep-blue max-h-[800px] overflow-y-auto rounded-3xl flex flex-col gap-4">
201218
{fields.map((field, index) => (
202219
<div key={index} className="w-full">
@@ -269,7 +286,6 @@ function MultipleGroupFields<T>({
269286
</div>
270287
</div>
271288
);
272-
273289
}
274290

275291
export function Fields<T>({
@@ -278,7 +294,7 @@ export function Fields<T>({
278294
onChange,
279295
defaultValues = [],
280296
allowEdit = true,
281-
onErrors
297+
onErrors,
282298
}: FieldProps<T>) {
283299
return (
284300
<MultipleGroupFields<T>
@@ -287,7 +303,10 @@ export function Fields<T>({
287303
onChange={onChange}
288304
defaultValues={defaultValues}
289305
allowEdit={allowEdit}
290-
onErrors={onErrors ?? ((errors) => errors.forEach((error) => newNotification(error, "error")))}
306+
onErrors={
307+
onErrors ??
308+
((errors) => errors.forEach((error) => newNotification(error, "error")))
309+
}
291310
/>
292311
);
293312
}
@@ -399,7 +418,7 @@ export function SocialMultipleFields({
399418
onChange,
400419
defaultValues = [],
401420
}: {
402-
onChange?: (data: Social[]) => void;
421+
onChange?: (data: Social[]) => void;
403422
defaultValues?: Social[];
404423
}) {
405424
const fields: GroupField<keyof Social>[] = [

0 commit comments

Comments
 (0)