Skip opening root document if delete originated from a file-restore (#27992)

* Skip opening root document if delete originated from a file-restore

* handle project-restore origin

* Refactor isFileRestore logic

GitOrigin-RevId: f2a34189140deb4e614d93e8d197b8a6a90c8f65
This commit is contained in:
Domagoj Kriskovic
2025-08-27 08:05:25 +00:00
committed by Copybot
parent fa9cea9f1d
commit dff92f1e6b
3 changed files with 23 additions and 8 deletions
@@ -121,10 +121,10 @@ export const FileTreeOpenProvider: FC<React.PropsWithChildren> = ({
)
const handleFileTreeDelete = useCallback(
(entity: FileTreeFindResult) => {
(entity: FileTreeFindResult, isFileRestore?: boolean) => {
eventEmitter.emit('entity:deleted', entity)
// Select the root document if the current document was deleted
if (entity.entity._id === currentDocumentId) {
// Select the root document if the current document was deleted and delete is not part of a file restore
if (!isFileRestore && entity.entity._id === currentDocumentId) {
openDocWithId(rootDocId!)
}
},