[WEB-6137] fix: work item peek view outside click #8610
This commit is contained in:
parent
dbe059b7b5
commit
a8d81656fc
3 changed files with 18 additions and 5 deletions
|
|
@ -96,7 +96,8 @@ export const IssueView = observer(function IssueView(props: IIssueView) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
issueId
|
issueId,
|
||||||
|
["main-sidebar"]
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleKeyDown = () => {
|
const handleKeyDown = () => {
|
||||||
|
|
|
||||||
|
|
@ -178,6 +178,7 @@ export function ResizableSidebar({
|
||||||
<>
|
<>
|
||||||
{/* Main Sidebar */}
|
{/* Main Sidebar */}
|
||||||
<div
|
<div
|
||||||
|
id="main-sidebar"
|
||||||
className={cn(
|
className={cn(
|
||||||
"h-full z-20 bg-surface-1 border-r border-subtle",
|
"h-full z-20 bg-surface-1 border-r border-subtle",
|
||||||
!isResizing && "transition-all duration-300 ease-in-out",
|
!isResizing && "transition-all duration-300 ease-in-out",
|
||||||
|
|
@ -192,6 +193,7 @@ export function ResizableSidebar({
|
||||||
}}
|
}}
|
||||||
role="complementary"
|
role="complementary"
|
||||||
aria-label="Main sidebar"
|
aria-label="Main sidebar"
|
||||||
|
data-prevent-outside-click={isMobile}
|
||||||
>
|
>
|
||||||
<aside
|
<aside
|
||||||
className={cn(
|
className={cn(
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,8 @@ import { useEffect, useCallback } from "react";
|
||||||
const usePeekOverviewOutsideClickDetector = (
|
const usePeekOverviewOutsideClickDetector = (
|
||||||
ref: React.RefObject<HTMLElement>,
|
ref: React.RefObject<HTMLElement>,
|
||||||
callback: () => void,
|
callback: () => void,
|
||||||
issueId: string
|
issueId: string,
|
||||||
|
excludePreventionElementIds?: string[]
|
||||||
) => {
|
) => {
|
||||||
const handleClick = useCallback(
|
const handleClick = useCallback(
|
||||||
(event: MouseEvent) => {
|
(event: MouseEvent) => {
|
||||||
|
|
@ -18,10 +19,19 @@ const usePeekOverviewOutsideClickDetector = (
|
||||||
if (ref.current && !ref.current.contains(event.target)) {
|
if (ref.current && !ref.current.contains(event.target)) {
|
||||||
// check for the closest element with attribute name data-prevent-outside-click
|
// check for the closest element with attribute name data-prevent-outside-click
|
||||||
const preventOutsideClickElement = event.target.closest("[data-prevent-outside-click]");
|
const preventOutsideClickElement = event.target.closest("[data-prevent-outside-click]");
|
||||||
// if the closest element with attribute name data-prevent-outside-click is found, return
|
// if the closest element with attribute name data-prevent-outside-click is found
|
||||||
if (preventOutsideClickElement) {
|
if (preventOutsideClickElement) {
|
||||||
|
// Check if this element's ID is in the exclusion list
|
||||||
|
const elementId = preventOutsideClickElement.id;
|
||||||
|
const shouldExcludePrevention =
|
||||||
|
excludePreventionElementIds && elementId && excludePreventionElementIds.includes(elementId);
|
||||||
|
|
||||||
|
if (!shouldExcludePrevention && !preventOutsideClickElement.contains(ref.current)) {
|
||||||
|
// Only prevent the callback if the ref is NOT inside the same prevent-outside-click container.
|
||||||
|
// This allows normal outside click detection for elements within the same container
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// check if the click target is the current issue element or its children
|
// check if the click target is the current issue element or its children
|
||||||
let targetElement: HTMLElement | null = event.target;
|
let targetElement: HTMLElement | null = event.target;
|
||||||
while (targetElement) {
|
while (targetElement) {
|
||||||
|
|
@ -43,7 +53,7 @@ const usePeekOverviewOutsideClickDetector = (
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[ref, callback, issueId]
|
[ref, callback, issueId, excludePreventionElementIds]
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue