From 6f73cb493955becfe52ee4c7094f0870b9483eb5 Mon Sep 17 00:00:00 2001 From: Nan Yu Date: Mon, 13 Dec 2021 13:21:03 -0800 Subject: [PATCH] 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 --- app/components/Button.tsx | 4 ++-- app/components/Sidebar/components/DocumentLink.tsx | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/components/Button.tsx b/app/components/Button.tsx index e8c1c0d42..baf6e5ef5 100644 --- a/app/components/Button.tsx +++ b/app/components/Button.tsx @@ -72,7 +72,7 @@ const RealButton = styled.button<{ fill: ${props.iconColor || props.theme.buttonNeutralText}; }` } - + &:hover:not(:disabled) { background: ${ @@ -100,7 +100,7 @@ const RealButton = styled.button<{ background: ${props.theme.danger}; color: ${props.theme.white}; - &:hover { + &:hover:not(:disabled) { background: ${darken(0.05, props.theme.danger)}; } `}; diff --git a/app/components/Sidebar/components/DocumentLink.tsx b/app/components/Sidebar/components/DocumentLink.tsx index f37a95387..f2258e545 100644 --- a/app/components/Sidebar/components/DocumentLink.tsx +++ b/app/components/Sidebar/components/DocumentLink.tsx @@ -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().id), + !isDraft && + !!pathToNode && + !pathToNode.includes(monitor.getItem().id), hover: (item, monitor) => { // Enables expansion of document children when hovering over the document // for more than half a second.