@open-mercato/ui 0.6.1-develop.3188.1.499d530779 → 0.6.1-develop.3198.1.aa979623f0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -267,6 +267,7 @@ function CrudForm({
267
267
  schema,
268
268
  fields,
269
269
  initialValues,
270
+ disableInitialFocus = false,
270
271
  submitLabel,
271
272
  submitIcon,
272
273
  formId: providedFormId,
@@ -1450,7 +1451,7 @@ function CrudForm({
1450
1451
  const lastErrorFieldRef = React.useRef(null);
1451
1452
  React.useEffect(() => {
1452
1453
  if (typeof window === "undefined" || typeof document === "undefined") return;
1453
- if (isLoading || isLoadingCustomFields || formReadOnly) {
1454
+ if (disableInitialFocus || isLoading || isLoadingCustomFields || formReadOnly) {
1454
1455
  lastFocusedFieldRef.current = null;
1455
1456
  return;
1456
1457
  }
@@ -1485,7 +1486,7 @@ function CrudForm({
1485
1486
  window.clearTimeout(frame);
1486
1487
  }
1487
1488
  };
1488
- }, [firstFieldId, formId, formReadOnly, isLoading, isLoadingCustomFields]);
1489
+ }, [disableInitialFocus, firstFieldId, formId, formReadOnly, isLoading, isLoadingCustomFields]);
1489
1490
  React.useEffect(() => {
1490
1491
  if (typeof window === "undefined" || typeof document === "undefined") return;
1491
1492
  const entries = Object.entries(errors);
@@ -2110,7 +2111,7 @@ function CrudForm({
2110
2111
  onBlurRequest,
2111
2112
  values,
2112
2113
  loadFieldOptions,
2113
- autoFocus: !formReadOnly && Boolean(firstFieldId && f.id === firstFieldId),
2114
+ autoFocus: !disableInitialFocus && !formReadOnly && Boolean(firstFieldId && f.id === firstFieldId),
2114
2115
  onSubmitRequest: requestSubmit,
2115
2116
  wrapperClassName,
2116
2117
  entityIdForField: primaryEntityId ?? void 0,
@@ -2600,7 +2601,7 @@ function CrudForm({
2600
2601
  onBlurRequest,
2601
2602
  values,
2602
2603
  loadFieldOptions,
2603
- autoFocus: !formReadOnly && Boolean(firstFieldId && f.id === firstFieldId),
2604
+ autoFocus: !disableInitialFocus && !formReadOnly && Boolean(firstFieldId && f.id === firstFieldId),
2604
2605
  onSubmitRequest: requestSubmit,
2605
2606
  wrapperClassName,
2606
2607
  entityIdForField: primaryEntityId ?? void 0,
@@ -3336,6 +3337,7 @@ const FieldControl = React.memo(
3336
3337
  onChange: (next) => fieldSetValue(next),
3337
3338
  placeholder,
3338
3339
  autoFocus: autoFocusField,
3340
+ suppressInitialSuggestionsOnFocus: autoFocusField,
3339
3341
  suggestions: options.map((opt) => ({ value: opt.value, label: opt.label })),
3340
3342
  loadSuggestions: typeof builtin?.loadOptions === "function" ? async (query) => {
3341
3343
  const opts = await loadFieldOptions(field, query);