Skip to content
This repository was archived by the owner on Jan 30, 2026. It is now read-only.

Commit c219ef8

Browse files
committed
refactor: reorder FieldMenu rendering logic for improved clarity and maintainability
1 parent 601e9ed commit c219ef8

1 file changed

Lines changed: 34 additions & 34 deletions

File tree

src/defaults/FieldMenu.tsx

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -62,40 +62,6 @@ export const FieldMenu: React.FC<FieldMenuProps> = ({
6262

6363
return (
6464
<div className="superdoc-field-menu" style={menuStyle}>
65-
{availableFields.map((field) => (
66-
<div
67-
key={field.id}
68-
className="field-menu-item"
69-
onClick={() => onSelect(field)}
70-
style={{
71-
padding: "8px 16px",
72-
cursor: "pointer",
73-
}}
74-
>
75-
<span style={{ fontWeight: 500 }}>{field.label}</span>
76-
{field.category && (
77-
<span
78-
style={{
79-
fontSize: "0.85em",
80-
color: "#666",
81-
marginLeft: "8px",
82-
}}
83-
>
84-
{field.category}
85-
</span>
86-
)}
87-
</div>
88-
))}
89-
90-
{allowCreate && availableFields.length > 0 && (
91-
<div
92-
style={{
93-
borderTop: "1px solid #eee",
94-
margin: "4px 0",
95-
}}
96-
/>
97-
)}
98-
9965
{allowCreate && !isCreating && (
10066
<div
10167
className="field-menu-item"
@@ -173,6 +139,40 @@ export const FieldMenu: React.FC<FieldMenuProps> = ({
173139
</div>
174140
)}
175141

142+
{allowCreate && availableFields.length > 0 && (
143+
<div
144+
style={{
145+
borderTop: "1px solid #eee",
146+
margin: "4px 0",
147+
}}
148+
/>
149+
)}
150+
151+
{availableFields.map((field) => (
152+
<div
153+
key={field.id}
154+
className="field-menu-item"
155+
onClick={() => onSelect(field)}
156+
style={{
157+
padding: "8px 16px",
158+
cursor: "pointer",
159+
}}
160+
>
161+
<span style={{ fontWeight: 500 }}>{field.label}</span>
162+
{field.category && (
163+
<span
164+
style={{
165+
fontSize: "0.85em",
166+
color: "#666",
167+
marginLeft: "8px",
168+
}}
169+
>
170+
{field.category}
171+
</span>
172+
)}
173+
</div>
174+
))}
175+
176176
<div
177177
style={{
178178
borderTop: "1px solid #eee",

0 commit comments

Comments
 (0)