fix: various bugs on draft sidebar items (#2856)

- show children when the only child is the active draft
- disable drop onto draft items
- fix danger button hover color
This commit is contained in:
Nan Yu
2021-12-13 13:21:03 -08:00
committed by GitHub
parent e1903c4016
commit 6f73cb4939
2 changed files with 7 additions and 4 deletions

View File

@@ -47,7 +47,8 @@ function DocumentLink(
const { documents, policies } = useStores();
const { t } = useTranslation();
const isActiveDocument = activeDocument && activeDocument.id === node.id;
const hasChildDocuments = !!node.children.length;
const hasChildDocuments =
!!node.children.length || activeDocument?.parentDocumentId === node.id;
const document = documents.get(node.id);
const { fetchChildDocuments } = documents;
const [isEditing, setIsEditing] = React.useState(false);
@@ -167,7 +168,9 @@ function DocumentLink(
documents.move(item.id, collection.id, node.id);
},
canDrop: (_item, monitor) =>
!!pathToNode && !pathToNode.includes(monitor.getItem<DragObject>().id),
!isDraft &&
!!pathToNode &&
!pathToNode.includes(monitor.getItem<DragObject>().id),
hover: (item, monitor) => {
// Enables expansion of document children when hovering over the document
// for more than half a second.