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
This commit is contained in:
@@ -26,7 +26,7 @@ const formatDate = (date) => {
|
||||
minute: 'numeric',
|
||||
month: 'short',
|
||||
year: 'numeric',
|
||||
}).format(date)
|
||||
}).format(new Date(date))
|
||||
}
|
||||
|
||||
export const DocumentLocked: React.FC<{
|
||||
|
||||
@@ -225,9 +225,14 @@ export function DefaultEditView({
|
||||
}
|
||||
setCurrentEditor(lockedState.user as ClientUser)
|
||||
}
|
||||
|
||||
// Update lastUpdateTime when lock state changes
|
||||
if (lockedState.lastEditedAt) {
|
||||
setLastUpdateTime(new Date(lockedState.lastEditedAt).getTime())
|
||||
}
|
||||
}
|
||||
},
|
||||
[documentLockState, setCurrentEditor, setDocumentIsLocked, user?.id],
|
||||
[documentLockState, setCurrentEditor, setDocumentIsLocked, setLastUpdateTime, user?.id],
|
||||
)
|
||||
|
||||
const handlePrevent = useCallback((nextHref: null | string) => {
|
||||
|
||||
Reference in New Issue
Block a user