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:
Patrik
2025-10-03 14:26:48 -04:00
committed by GitHub
parent 9fcd1fa8f1
commit 394000d07c
2 changed files with 7 additions and 2 deletions

View File

@@ -26,7 +26,7 @@ const formatDate = (date) => {
minute: 'numeric',
month: 'short',
year: 'numeric',
}).format(date)
}).format(new Date(date))
}
export const DocumentLocked: React.FC<{

View File

@@ -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) => {