smoodly 0.0.55 → 0.0.57

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.
@@ -23,10 +23,11 @@ export function PageSettings({ record, locale, registry, path, fixed, redirects,
23
23
  /** One commit at a time: Enter commits, then the confirm's autofocus blurs the input, and that blur must not ask again. */
24
24
  const committing = useRef(false);
25
25
  const isHome = record.parentId === null && record.locales[registry.locales.default]?.slug === registry.homePageSlug;
26
- // The record changes identity on every rename; re-seed the inputs from it.
26
+ // Re-seed the inputs when the stored title or slug changes (a rename, a locale switch, a restore) — not on the
27
+ // record's identity: every autosave ack replaces the record, and typing in a field meanwhile must survive it.
27
28
  useEffect(() => {
28
29
  setDraft({ title: row?.title ?? "", slug: row?.slug ?? "" });
29
- }, [record, locale]); // eslint-disable-line react-hooks/exhaustive-deps
30
+ }, [row?.title, row?.slug, locale]); // eslint-disable-line react-hooks/exhaustive-deps
30
31
  if (!row)
31
32
  return null;
32
33
  const commit = async (key) => {
@@ -102,12 +102,15 @@ export function createGlobalEdit(opts) {
102
102
  },
103
103
  flush: autosave.flush,
104
104
  async setStatus(name, status) {
105
- const item = items[name];
106
- if (!item)
105
+ if (!items[name])
107
106
  return { ok: false, code: "not_found", message: "This item hasn't loaded yet." };
108
107
  if (!(await autosave.flush())) {
109
108
  return { ok: false, code: "internal", message: "Couldn't save your latest changes — publish cancelled." };
110
109
  }
110
+ // Read the item after the flush: a save it landed replaced the record, and with it the token.
111
+ const item = items[name];
112
+ if (!item)
113
+ return { ok: false, code: "not_found", message: "This item hasn't loaded yet." };
111
114
  let r;
112
115
  try {
113
116
  r = await opts.ops.globals.setStatus(name, item.locale, status, draftToken(item.record.locales[item.locale]));