@viliha/vui-ui 1.6.2 → 1.6.3

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.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,18 @@ backward-compatible features, **major** for breaking changes.
7
7
 
8
8
  To upgrade, see [Upgrading](./AGENT.md#upgrading) in the agent guide.
9
9
 
10
+ ## 1.6.3 — 2026-07-25
11
+
12
+ ### Fixed
13
+
14
+ - `RecordForm` no longer loses in-progress input when switching tabs **in dev**.
15
+ The draft persistence (`persistKey`) used a first-write flag that React
16
+ StrictMode's effect double-invoke defeated: the second pass wrote the empty
17
+ initial value over the draft the restore effect was about to bring back. The
18
+ writer now skips the untouched seed by identity, so it never clobbers a stored
19
+ draft. (Production builds, which don't run StrictMode's double-invoke, were
20
+ unaffected.)
21
+
10
22
  ## 1.6.2 — 2026-07-25
11
23
 
12
24
  ### Fixed
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@viliha/vui-ui",
3
- "version": "1.6.2",
3
+ "version": "1.6.3",
4
4
  "description": "Vui UI — a clean, token-driven React admin/CRM component library built on Tailwind CSS v4, shadcn-style patterns, and Radix Icons. Ships as TypeScript source (Just-in-Time), compiled by the consuming app.",
5
5
  "license": "MIT",
6
6
  "author": "Suman Bonakurthi",
@@ -214,7 +214,13 @@ function usePersistentState<T>(
214
214
  initial: T,
215
215
  ): [T, React.Dispatch<React.SetStateAction<T>>] {
216
216
  const [state, setState] = React.useState<T>(initial);
217
- const firstWrite = React.useRef(true);
217
+ // Stable reference to the seeded value. The writer skips it by identity (not a
218
+ // first-write flag) so the write is StrictMode-safe: dev double-invokes the
219
+ // write effect while `state` is still `initial`, and a flag flips on the first
220
+ // pass so the second pass would persist `initial` OVER a draft the restore
221
+ // effect is about to bring back. Comparing to this ref never writes `initial`,
222
+ // so it can't clobber the stored draft.
223
+ const initialRef = React.useRef(initial);
218
224
  React.useEffect(() => {
219
225
  if (!key) return;
220
226
  try {
@@ -226,10 +232,9 @@ function usePersistentState<T>(
226
232
  }, [key]);
227
233
  React.useEffect(() => {
228
234
  if (!key) return;
229
- if (firstWrite.current) {
230
- firstWrite.current = false; // don't overwrite stored value with `initial`
231
- return;
232
- }
235
+ // Nothing to save while still the untouched seed; only a restore or a user
236
+ // edit diverges `state` from it, and both should persist.
237
+ if (state === initialRef.current) return;
233
238
  try {
234
239
  sessionStorage.setItem(key, JSON.stringify(state));
235
240
  } catch {