Skip to content

Commit

Permalink
Fix hovering and delete button issues in backlog view (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
maximilianruesch authored Dec 3, 2023
1 parent a48f96c commit 7273237
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
20 changes: 16 additions & 4 deletions src/components/BacklogView/Issue/DeleteButton.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ActionIcon, Transition, Popover, Box } from "@mantine/core"
import { IconTrash } from "@tabler/icons"
import { useEffect, useState } from "react"
import { useHover } from "@mantine/hooks";
import { DeleteIssueAlert } from "../../DetailView/Components/DeleteIssue/DeleteIssueAlert"

export function DeleteButton({
Expand All @@ -11,15 +12,16 @@ export function DeleteButton({
issueKey: string
}) {
const [issuePopoverOpened, setIssuePopoverOpened] = useState(false)
const { ref, hovered } = useHover()

useEffect(() => {
if (!mounted) {
if (!mounted && !hovered) {
setIssuePopoverOpened(false)
}
}, [mounted])
}, [mounted, hovered])

return (
<Box sx={{ position: "absolute", bottom: 5, right: 11 }}>
<Box ref={ref} sx={{ position: "absolute", bottom: 5, right: 11 }}>
<Transition
mounted={mounted}
transition="fade"
Expand All @@ -41,7 +43,10 @@ export function DeleteButton({
size="sm"
variant="transparent"
style={styles}
onClick={() => setIssuePopoverOpened(!issuePopoverOpened)}
onClick={(e) => {
e.stopPropagation()
setIssuePopoverOpened(!issuePopoverOpened)
}}
>
<IconTrash />
</ActionIcon>
Expand All @@ -54,6 +59,13 @@ export function DeleteButton({
: theme.white,
})}
>
<div style={{
height: "20px",
position: "absolute",
width: "inherit",
left: "0px",
top: "-10px",
}} />
<DeleteIssueAlert
issueKey={issueKey}
closeModal={() => setIssuePopoverOpened(false)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ export function DeleteIssueAlert({
If you delete this issue, all related subtasks will be deleted as well!
</Alert>
<Button
onClick={() => {
closeModal()
onClick={(e) => {
e.stopPropagation()
deleteIssue.mutate(issueKey)
closeModal()
}}
>
Confirm
Expand Down

0 comments on commit 7273237

Please sign in to comment.