@@ -10,7 +10,6 @@ import {
10
10
FormBuilder ,
11
11
type FormDocumentValue ,
12
12
fromMutationPatches ,
13
- LoadingBlock ,
14
13
type PatchMsg ,
15
14
PresenceOverlay ,
16
15
useDocumentPresence ,
@@ -48,6 +47,7 @@ export const FormView = forwardRef<HTMLDivElement, FormViewProps>(function FormV
48
47
ready,
49
48
formState,
50
49
onFocus,
50
+ connectionState,
51
51
onBlur,
52
52
onSetCollapsedPath,
53
53
onPathOpen,
@@ -148,10 +148,6 @@ export const FormView = forwardRef<HTMLDivElement, FormViewProps>(function FormV
148
148
// [documentId]
149
149
// )
150
150
151
- if ( ! ready ) {
152
- return < LoadingBlock showText />
153
- }
154
-
155
151
return (
156
152
< Container
157
153
hidden = { hidden }
@@ -163,49 +159,7 @@ export const FormView = forwardRef<HTMLDivElement, FormViewProps>(function FormV
163
159
>
164
160
< PresenceOverlay margins = { margins } >
165
161
< Box as = "form" onSubmit = { preventDefault } ref = { setRef } >
166
- { ready ? (
167
- formState === null || hidden ? (
168
- < Box padding = { 2 } >
169
- < Text > { t ( 'document-view.form-view.form-hidden' ) } </ Text >
170
- </ Box >
171
- ) : (
172
- < >
173
- < FormHeader
174
- documentId = { documentId }
175
- schemaType = { formState . schemaType }
176
- title = { title }
177
- />
178
- < FormBuilder
179
- __internal_fieldActions = { fieldActions }
180
- __internal_patchChannel = { patchChannel }
181
- collapsedFieldSets = { collapsedFieldSets }
182
- collapsedPaths = { collapsedPaths }
183
- focusPath = { formState . focusPath }
184
- changed = { formState . changed }
185
- focused = { formState . focused }
186
- groups = { formState . groups }
187
- id = "root"
188
- members = { formState . members }
189
- onChange = { onChange }
190
- onFieldGroupSelect = { onSetActiveFieldGroup }
191
- onPathBlur = { onBlur }
192
- onPathFocus = { onFocus }
193
- onPathOpen = { onPathOpen }
194
- onSetFieldSetCollapsed = { onSetCollapsedFieldSet }
195
- onSetPathCollapsed = { onSetCollapsedPath }
196
- presence = { presence }
197
- readOnly = { formState . readOnly }
198
- schemaType = { formState . schemaType }
199
- validation = { validation }
200
- value = {
201
- // note: the form state doesn't have a typed concept of a "document" value
202
- // but these should be compatible
203
- formState . value as FormDocumentValue
204
- }
205
- />
206
- </ >
207
- )
208
- ) : (
162
+ { connectionState === 'connecting' ? (
209
163
< Delay ms = { 300 } >
210
164
{ /* TODO: replace with loading block */ }
211
165
< Flex align = "center" direction = "column" height = "fill" justify = "center" >
@@ -217,6 +171,42 @@ export const FormView = forwardRef<HTMLDivElement, FormViewProps>(function FormV
217
171
</ Box >
218
172
</ Flex >
219
173
</ Delay >
174
+ ) : formState === null || hidden ? (
175
+ < Box padding = { 2 } >
176
+ < Text > { t ( 'document-view.form-view.form-hidden' ) } </ Text >
177
+ </ Box >
178
+ ) : (
179
+ < >
180
+ < FormHeader documentId = { documentId } schemaType = { formState . schemaType } title = { title } />
181
+ < FormBuilder
182
+ __internal_fieldActions = { fieldActions }
183
+ __internal_patchChannel = { patchChannel }
184
+ collapsedFieldSets = { collapsedFieldSets }
185
+ collapsedPaths = { collapsedPaths }
186
+ focusPath = { formState . focusPath }
187
+ changed = { formState . changed }
188
+ focused = { formState . focused }
189
+ groups = { formState . groups }
190
+ id = "root"
191
+ members = { formState . members }
192
+ onChange = { onChange }
193
+ onFieldGroupSelect = { onSetActiveFieldGroup }
194
+ onPathBlur = { onBlur }
195
+ onPathFocus = { onFocus }
196
+ onPathOpen = { onPathOpen }
197
+ onSetFieldSetCollapsed = { onSetCollapsedFieldSet }
198
+ onSetPathCollapsed = { onSetCollapsedPath }
199
+ presence = { presence }
200
+ readOnly = { connectionState === 'reconnecting' || formState . readOnly }
201
+ schemaType = { formState . schemaType }
202
+ validation = { validation }
203
+ value = {
204
+ // note: the form state doesn't have a typed concept of a "document" value
205
+ // but these should be compatible
206
+ formState . value as FormDocumentValue
207
+ }
208
+ />
209
+ </ >
220
210
) }
221
211
</ Box >
222
212
</ PresenceOverlay >
0 commit comments