Skip to content

Commit 394000d

Browse files
authored
fix(ui): invalid time value error when document locking with autosave enabled (#14062)
### What? Fixes "Invalid time value" error in the DocumentLocked modal when displaying the last edited timestamp. ### Why? The `formatDate` function was passing a timestamp number directly to `Intl.DateTimeFormat().format()`, which expects a Date object. When `updatedAt` is a number (timestamp), this causes an "Invalid time value" error. ### How? Wrap the date parameter with `new Date()` before passing it to `Intl.DateTimeFormat().format()` to properly convert the timestamp to a Date object. Fixes #14016
1 parent 9fcd1fa commit 394000d

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

packages/ui/src/elements/DocumentLocked/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const formatDate = (date) => {
2626
minute: 'numeric',
2727
month: 'short',
2828
year: 'numeric',
29-
}).format(date)
29+
}).format(new Date(date))
3030
}
3131

3232
export const DocumentLocked: React.FC<{

packages/ui/src/views/Edit/index.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,14 @@ export function DefaultEditView({
225225
}
226226
setCurrentEditor(lockedState.user as ClientUser)
227227
}
228+
229+
// Update lastUpdateTime when lock state changes
230+
if (lockedState.lastEditedAt) {
231+
setLastUpdateTime(new Date(lockedState.lastEditedAt).getTime())
232+
}
228233
}
229234
},
230-
[documentLockState, setCurrentEditor, setDocumentIsLocked, user?.id],
235+
[documentLockState, setCurrentEditor, setDocumentIsLocked, setLastUpdateTime, user?.id],
231236
)
232237

233238
const handlePrevent = useCallback((nextHref: null | string) => {

0 commit comments

Comments
 (0)