Replies: 1 comment 3 replies
-
|
@linesh98 Could you also attach snapshots of the pages with this problem? You can take snapshots of pages using this extension: https://chromewebstore.google.com/detail/singlefile/mpiodijhokgodhhofbcjdecpffjipkle?pli=1 |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am using the licensed version of FormBuilder and trying to create a better view. I am hiding the left and right panels to expand the designer area. The layout works correctly in the expanded view, but the alignment breaks in the shrunk (normal) view when the panels are visible again. I am facing alignment issues because the layout changes between the expanded view and the normal designer view. This is also affecting other parts of my application where the same UI behavior is used. How can I fix this issue? Below I will provide my current code and screenshots.
how to fix this mismatch, because my other page in the application, that is using template breaking the layout, it is using a modal to display the form

belwo i will provid ethe designer and modal using code
`// src/pages/private/form-builder/Designer.tsx
import { useCallback, useEffect, useMemo } from "react";
import { FormBuilder, useFormBuilder, type BuilderView } from "@react-form-builder/designer";
import {
components as rsuiteComponents,
formEngineRsuiteCssLoader,
ltrCssLoader,
rtlCssLoader,
RsLocalizationWrapper,
rSuiteComponentsDescriptions,
} from "@react-form-builder/components-rsuite";
import { rSuiteTableComponentsDescriptions } from "@react-form-builder/components-rsuite-table";
import {
fastQrComponent,
fastQrComponentsDescriptions,
} from "@react-form-builder/components-fast-qr";
import {
googleMapComponent,
googleMapComponentsDescriptions,
} from "@react-form-builder/components-google-map";
import {
richTextComponent,
richTextEditorComponentsDescriptions,
} from "@react-form-builder/components-rich-text";
import {
signatureComponent,
signatureComponentsDescriptions,
} from "@react-form-builder/components-signature";
import { BiDi, BuilderView as CoreBuilderView } from "@react-form-builder/core";
import ButtonComponent from "../../../components/general/ButtonComponent";
import { voiceTextInput } from "./VoiceTextInputDef";
import { textEditor } from "./TextEditorDef";
/* -------------------------------------------------------------------------- /
/ Toggle Builder / Preview Mode Button /
/ -------------------------------------------------------------------------- */
const CustomToggleModeButton = () => {
const builder = useFormBuilder();
const label = builder.builderMode === "builder" ? "Preview Mode" : "Edit Mode";
const toggleMode = useCallback(() => {
const newMode = builder.builderMode === "builder" ? "viewer" : "builder";
builder.builderMode = newMode;
}, [builder]);
return {label};
};
/* -------------------------------------------------------------------------- /
/ Builder Customizations /
/ -------------------------------------------------------------------------- */
const builderCustomizations = {
JsonViewButton: { hidden: true },
MainMenu_Button: { hidden: true },
ResolutionSelect: { hidden: true },
ToggleThemeButton: { hidden: true },
Actions_Tab: { hidden: true },
Actions_Tab_Content: { hidden: true },
LocalizationSelect: { hidden: true },
ToggleModeButton: { hidden: true },
Header_Toolbar: { hidden: true },
MainMenu_Dropdown: {
style:
#menuitem-\\:r5\\:, #menuitem-\\:r6\\: { display: none; },},
Header: {
customRenderer: () => (
<>
<style>
{
.hidden-panel { display: none !important; }}</style>
<div
style={{
display: "flex",
justifyContent: "flex-end",
padding: "0.5rem",
}}
>
</>
),
},
};
/* -------------------------------------------------------------------------- /
/ Props /
/ -------------------------------------------------------------------------- */
interface DesignerProps {
onRefReady: (ref: any) => void;
onDataChange: (data: any) => void;
}
/* -------------------------------------------------------------------------- /
/ Designer Component /
/ -------------------------------------------------------------------------- */
export const Designer = ({ onRefReady, onDataChange }: DesignerProps) => {
/* ------------------------ Register ALL components ------------------------ */
const allComponents = useMemo(
() => [
...rsuiteComponents,
fastQrComponent.build(),
googleMapComponent.build(),
signatureComponent.build(),
richTextComponent.build(),
voiceTextInput.build(),
textEditor.build(),
],
[],
);
useEffect(() => {
if (globalThis.crypto && typeof globalThis.crypto.subtle === "undefined") {
Object.defineProperty(globalThis.crypto, "subtle", {
value: {
verify: async () => true,
importKey: async () => ({}),
},
configurable: true,
});
}
}, []);
/* ------------------------- Create Builder View --------------------------- */
const view = useMemo(() => {
return (
new CoreBuilderView(allComponents)
.withViewerWrapper(RsLocalizationWrapper)
.withCssLoader(BiDi.LTR, ltrCssLoader)
.withCssLoader(BiDi.RTL, rtlCssLoader)
.withCssLoader("common", formEngineRsuiteCssLoader)
}, [allComponents]);
const licenseKey = import.meta.env.VITE_LICENSE_KEY;
return (
<FormBuilder
licenseKey={licenseKey}
view={view}
customization={builderCustomizations}
builderRef={(ref) => ref && onRefReady(ref)}
onFormDataChange={({ data }) => onDataChange(data)}
/>
);
};
`
and modal using like
`import styled from "styled-components";
import { useEffect, useRef, useState } from "react";
import ViewerPage from "../customform/ViewerPage";
import ButtonComponent from "../../../components/general/ButtonComponent";
import { useGetAllTemplatesFormQuery } from "../../../store/services/DoctorsWorkBenchApis/doctorsWorkbenchApi";
import { LoadForm } from "../customform/LoadForm";
import { IMAGE_ROOT_PATH_URL } from "../../../utils/general/constants";
import SavedFormExpandModal from "../../../components/modals/doctors-workbench/clinical-forms/SavedFormExpandModal";
import { useGetScopeForPermissionsQuery } from "../../../store/services/administration/AdministrationApi";
import { ScopePermissionsConstants } from "../../../utils/administration/adminConstants";
import { scopeFinder } from "../../../utils/administration/scopeFinder";
const SavedFormsStructure = () => {
const viewerRef = useRef<{ handleSave: () => void } | null>(null);
const [formList, setFormList] = useState<{ id: number; name: string }[]>([]);
const [selectedForm, setSelectedForm] = useState<number | null>(null);
const [alreadyFilled, setAlreadyFilled] = useState(false);
const [isDirty, setIsDirty] = useState(false);
// const [isModalOpen, setIsModalOpen] = useState(false);
// const [refreshKey, setRefreshKey] = useState(0);
const [isExpanded, setIsExpanded] = useState(false);
const { data: templates } = useGetAllTemplatesFormQuery({
isAdvanceSearch: false,
pageSize: 1000,
pageCount: 1,
timePeriodFilterType: 0,
isDirectSearch: false,
directSearch: [],
advanceSearch: [],
userId: parseInt(localStorage.getItem("userId") ?? "0") ?? 0,
});
useEffect(() => {
if (templates?.data?.templateList?.length) {
setFormList(templates.data.templateList.map(({ id, name }) => ({ id, name })));
}
}, [templates]);
const { data: scopes } = useGetScopeForPermissionsQuery([
ScopePermissionsConstants.DWB_OutPatient_ClinicalForms,
]);
const ClinicalFormsTabPermissions = scopeFinder(
scopes,
ScopePermissionsConstants.DWB_OutPatient_ClinicalForms,
);
return (
<ExpandButton
onClick={() => {
if (selectedForm) {
setIsExpanded(true);
}
}}
>
<img
src={
${IMAGE_ROOT_PATH_URL}/EmployeeProfileImages/CTA Buttons_20260212055630316.svg}/>
);
};
export default SavedFormsStructure;
const Wrapper = styled.div
width: 100%; height: calc(100vh - 19rem); padding: 0.75rem 1rem; box-sizing: border-box;;const Container = styled.div
height: 100%; display: flex; flex-direction: column; background: #fff; border: 1px solid #e5e5e5; border-radius: 6px; overflow: hidden;;const TopBar = styled.div
flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid #eee; background: #fafafa;;const ExpandButton = styled.button`
border: none;
background: transparent;
cursor: pointer;
font-size: 18px;
color: #666;
&:hover {
color: #000;
}
`;
const Content = styled.div
flex: 1; overflow-y: auto; padding: 16px;;const Footer = styled.div
flex-shrink: 0; padding: 12px 16px; border-top: 1px solid #eee; display: flex; justify-content: flex-end; background: #fff;;`
and
`import { useEffect, useRef, useState } from "react";
import { CustomizationMap, FormBuilder, type IFormBuilder } from "@react-form-builder/designer";
import { builderViewWithCss } from "@react-form-builder/components-rsuite";
import { toast } from "react-toastify";
import { useParams } from "react-router-dom";
import { voiceTextInput } from "./VoiceTextInputDef";
import type { BuilderView } from "@react-form-builder/designer";
import { useMemo } from "react";
import { textEditor } from "./TextEditorDef";
import {
useLazyGetTemplateByIdFormQuery,
useLazyGetAllFormEntriesQuery,
useSaveFormEntryMutation,
} from "../../../store/services/DoctorsWorkBenchApis/doctorsWorkbenchApi";
import { IFormViewer } from "@react-form-builder/core";
import { forwardRef, useImperativeHandle } from "react";
import styled from "styled-components";
import { IMAGE_ROOT_PATH_URL } from "../../../utils/general/constants";
import { ensureCryptoSubtle } from "../../../utils/doctors-workbench/cryptoFix";
import { getDisableConsultationEdit } from "../../../store/features/doctors-workbench/consultations/VitalSignsSlice";
import { useAppSelector } from "../../../store/hooks";
interface ViewerPageProps {
selectedForm: number | null;
onStateChange: (state: { alreadyFilled: boolean; isDirty: boolean }) => void;
onSaveSuccess?: () => void;
}
const ViewerPage = forwardRef<{ handleSave: () => void }, ViewerPageProps>(
({ selectedForm, onStateChange, onSaveSuccess }, ref) => {
const builderRef = useRef<IFormBuilder | null>(null);
const viewerRef = useRef<IFormViewer | null>(null);
const disableModify = useAppSelector(getDisableConsultationEdit);
},
);
export default ViewerPage;
const NoDataWrapper = styled.div
height: 100%; display: flex; align-items: center; justify-content: center;;const NoDataContent = styled.div`
text-align: center;
color: #888;
margin-top: 2rem;
p {
/* margin: 8px 0 4px; */
font-weight: 500;
}
span {
font-size: 0.8rem;
}
; const InfoBanner = styled.divbackground: #f0f4ff;
color: #2f54eb;
border: 1px solid #d6e4ff;
padding: 8px 12px;
border-radius: 4px;
margin-bottom: 12px;
font-size: 0.875rem;
;and
`// import styled from "styled-components";
// import ModalWrapper from "../../general/ModalWrapper";
// import ModalFormLayOut from "../../general/ModalFormLayout";
import { styled } from "styled-components";
import ModalFormLayOut from "../../general/ModalFormLayout";
import ModalWrapper from "../../general/ModalWrapper";
// import { useRef, useState } from "react";
// import ViewerPage from "../../../../views/doctors-workbench/customform/ViewerPage";
// import ButtonComponent from "../../../general/ButtonComponent";
// interface SavedFormExpandModalProps {
// isOpen: boolean;
// selectedForm: number | null;
// setOpen: () => void;
// onSaved: () => void;
// }
// const SavedFormExpandModal = ({
// isOpen,
// selectedForm,
// setOpen,
// onSaved,
// }: SavedFormExpandModalProps) => {
// const viewerRef = useRef<{ handleSave: () => void } | null>(null);
// const [alreadyFilled, setAlreadyFilled] = useState(false);
// const [isDirty, setIsDirty] = useState(false);
// if (!isOpen) return null;
// return (
//
//
//
// <ViewerPage
// ref={viewerRef}
// selectedForm={selectedForm}
// showAlreadyFilledToast={false}
// onStateChange={({ alreadyFilled, isDirty }) => {
// setAlreadyFilled(alreadyFilled);
// setIsDirty(isDirty);
// }}
// onSaveSuccess={() => {
// onSaved();
// setOpen();
// }}
// />
//
// <ButtonComponent
// onClick={() => viewerRef.current?.handleSave()}
// disabled={!selectedForm || alreadyFilled || !isDirty}
// >
// Save Form
//
//
//
//
//
// );
// };
// export default SavedFormExpandModal;
// const ModalContent = styled.div`
// display: flex;
// flex-direction: column;
// max-height: 80vh;
// min-height: 60vh;
// max-width: 70vw;
// overflow: hidden;
// > div:first-child {
// flex: 1;
// overflow-y: auto;
// }
// `;
// const Footer = styled.div
// padding-top: 1rem; // display: flex; // justify-content: flex-end; //;interface SavedFormExpandModalProps {
isOpen: boolean;
setOpen: () => void;
children: React.ReactNode;
}
const SavedFormExpandModal = ({ isOpen, setOpen, children }: SavedFormExpandModalProps) => {
if (!isOpen) return null;
return (
{children}
);
};
export default SavedFormExpandModal;
const ViewerModal = styled.div`
padding-left: 1.5rem;
padding-right: 1.5rem;
padding-bottom: 0.5rem;
display: flex;
flex-direction: column;
height: 80vh;
width: 60vw;
.form-scroll {
flex: 1;
overflow-y: auto;
padding-right: 1rem;
}
.modal-footer {
flex-shrink: 0;
padding: 16px;
border-top: 1px solid #eee;
display: flex;
justify-content: flex-end;
background: #fff;
}
;In the above code, when selecting a form, it is displayed normally in the UI and works correctly without any alignment issues. However, when I use the expanded view (where the form opens in a modal), the layout breaks and the alignment changes. Kindly provide a solution to fix this issue.
Beta Was this translation helpful? Give feedback.
All reactions