mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-10 22:09:01 +08:00
fix: expand and unexpand on active span path
This commit is contained in:
parent
c9b07ee5dd
commit
e7d2bb13dc
@ -41,8 +41,14 @@ const Trace = (props: TraceProps): JSX.Element => {
|
|||||||
const { isDarkMode } = useThemeMode()
|
const { isDarkMode } = useThemeMode()
|
||||||
const [isOpen, setOpen] = useState<boolean>(activeSpanPath[level] === id);
|
const [isOpen, setOpen] = useState<boolean>(activeSpanPath[level] === id);
|
||||||
|
|
||||||
|
const localTreeExpandInteraction = useRef<boolean | 0>(0); // Boolean is for the state of the expansion whereas the number i.e. 0 is for skipping the user interaction.
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isOpen) {
|
if (localTreeExpandInteraction.current !== 0) {
|
||||||
|
setOpen(localTreeExpandInteraction.current);
|
||||||
|
localTreeExpandInteraction.current = 0;
|
||||||
|
}
|
||||||
|
else if (!isOpen) {
|
||||||
setOpen(activeSpanPath[level] === id)
|
setOpen(activeSpanPath[level] === id)
|
||||||
}
|
}
|
||||||
}, [activeSpanPath, isOpen])
|
}, [activeSpanPath, isOpen])
|
||||||
@ -82,6 +88,11 @@ const Trace = (props: TraceProps): JSX.Element => {
|
|||||||
const onClick = () => {
|
const onClick = () => {
|
||||||
setActiveSelectedId(id);
|
setActiveSelectedId(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const onClickTreeExpansion = (event) => {
|
||||||
|
event.stopPropagation()
|
||||||
|
setOpen((state) => { localTreeExpandInteraction.current = !isOpen; return !state });
|
||||||
|
}
|
||||||
const { totalSpans } = getMetaDataFromSpanTree(props);
|
const { totalSpans } = getMetaDataFromSpanTree(props);
|
||||||
|
|
||||||
const inMsCount = value;
|
const inMsCount = value;
|
||||||
@ -113,10 +124,7 @@ const Trace = (props: TraceProps): JSX.Element => {
|
|||||||
{totalSpans !== 1 && (
|
{totalSpans !== 1 && (
|
||||||
<CardComponent
|
<CardComponent
|
||||||
isDarkMode={isDarkMode}
|
isDarkMode={isDarkMode}
|
||||||
onClick={(e) => {
|
onClick={onClickTreeExpansion}
|
||||||
e.stopPropagation()
|
|
||||||
setOpen((state) => !state);
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
{totalSpans}
|
{totalSpans}
|
||||||
<CaretContainer>
|
<CaretContainer>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user