Skip to content

Commit 5826ef0

Browse files
authored
fix: toggle into, policy and cofirmation open from TreeView (#5511)
* handle toggle open
1 parent a621ec9 commit 5826ef0

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

app/(gcforms)/[locale]/(form administration)/form-builder/[id]/edit/components/EditWithGroups.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ export const EditWithGroups = ({ id, locale }: { id: string; locale: string }) =
143143
{/* Form Intro + Title Panel */}
144144
{groupId === "start" && (
145145
<RichTextLocked
146+
id="intro"
146147
maxLength={20000}
147148
hydrated={hasHydrated}
148149
className="rounded-t-lg"
@@ -182,6 +183,7 @@ export const EditWithGroups = ({ id, locale }: { id: string; locale: string }) =
182183
{/* Privacy Panel */}
183184
{groupId === "start" && (
184185
<RichTextLocked
186+
id="policy"
185187
maxLength={50000}
186188
beforeContent={<PrivacyDescriptionBefore />}
187189
summaryText={t("groups.privacy.summary")}
@@ -211,6 +213,7 @@ export const EditWithGroups = ({ id, locale }: { id: string; locale: string }) =
211213
{/* Confirmation*/}
212214
{groupId === "end" && (
213215
<RichTextLocked
216+
id={"end"}
214217
maxLength={20000}
215218
summaryText={t("groups.confirmation.summary")}
216219
beforeContent={

app/(gcforms)/[locale]/(form administration)/form-builder/[id]/edit/components/elements/RichTextLocked.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { cn } from "@lib/utils";
1111
import Skeleton from "react-loading-skeleton";
1212

1313
export const RichTextLocked = ({
14+
id,
1415
beforeContent = null,
1516
summaryText,
1617
detailsText,
@@ -22,6 +23,7 @@ export const RichTextLocked = ({
2223
hydrated,
2324
maxLength,
2425
}: {
26+
id: string;
2527
beforeContent?: React.ReactElement | null;
2628
summaryText: string;
2729
detailsText?: React.ReactElement;
@@ -58,7 +60,7 @@ export const RichTextLocked = ({
5860
<EssentialBadge />
5961
{beforeContent && beforeContent}
6062
<div className="flex">{children}</div>
61-
<details>
63+
<details id={id}>
6264
<summary className="cursor-pointer text-sm font-bold underline">{summaryText}</summary>
6365
{detailsText && detailsText}
6466

app/(gcforms)/[locale]/(form administration)/form-builder/components/shared/right-panel/treeview/Item.tsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,30 @@ export const Item = ({
138138
isSectionElement && sectionElementClasses,
139139
isFormElement && formElementClasses
140140
)}
141+
{...(isLocked && {
142+
onClick: () => {
143+
if (
144+
item.index === "intro" ||
145+
item.index === "policy" ||
146+
item.index === "end" ||
147+
item.index === "confirmation"
148+
) {
149+
let index = item.index;
150+
if (index === "confirmation") {
151+
index = "end";
152+
}
153+
154+
// add small delay to allow the click to be registered
155+
setTimeout(() => {
156+
const el = document.getElementById(index);
157+
if (el) {
158+
(el as HTMLDetailsElement).open = true;
159+
el.scrollIntoView({ behavior: "smooth", block: "center" });
160+
}
161+
}, 200);
162+
}
163+
},
164+
})}
141165
{...(allowRename && {
142166
onDoubleClick: () => {
143167
context.startRenamingItem();

0 commit comments

Comments
 (0)