fix first tab separator issue while dragging

This commit is contained in:
Red Adaya 2024-12-10 11:29:43 +08:00
parent 9c51bca2e6
commit 4a366e3fba
2 changed files with 4 additions and 5 deletions

View File

@ -256,8 +256,6 @@ const Tab = memo(
} }
if (rightAdjacentId) { if (rightAdjacentId) {
console.log("rightAdjacentId!!!!!", rightAdjacentId);
// To check if rightAdjacentElement is the active tab then do not reset opacity // To check if rightAdjacentElement is the active tab then do not reset opacity
const rightAdjacentElement = document.querySelector( const rightAdjacentElement = document.querySelector(
`[data-tab-id="${rightAdjacentId}"]` `[data-tab-id="${rightAdjacentId}"]`
@ -266,6 +264,7 @@ const Tab = memo(
const separator = rightAdjacentElement.querySelector(".separator") as HTMLElement; const separator = rightAdjacentElement.querySelector(".separator") as HTMLElement;
if (!rightAdjacentElement.classList.contains("active")) { if (!rightAdjacentElement.classList.contains("active")) {
console.log("here!!!!!");
separator.style.opacity = "1"; // Reset opacity for the right adjacent tab separator.style.opacity = "1"; // Reset opacity for the right adjacent tab
} }
} }
@ -303,7 +302,7 @@ const Tab = memo(
reset(); reset();
}; };
} else { } else {
console.log("entered else ?????????????????????????"); console.log("entered else ?????????????????????????", tabsSwapped);
reset(); reset();
} }
}, [id, tabIds, isFirst, isActive, draggingId, tabsSwapped]); }, [id, tabIds, isFirst, isActive, draggingId, tabsSwapped]);

View File

@ -435,7 +435,7 @@ const TabBar = memo(({ workspace }: TabBarProps) => {
// } // }
// Update to trigger in-tab re-render // Update to trigger in-tab re-render
setTabsSwapped(newTabIndex); setTabsSwapped(newTabIndex + 1);
tabIds.splice(newTabIndex, 0, tabId); tabIds.splice(newTabIndex, 0, tabId);
@ -522,7 +522,7 @@ const TabBar = memo(({ workspace }: TabBarProps) => {
} }
// setTabIndicesMoved([]); // setTabIndicesMoved([]);
setTabsSwapped(false); setTabsSwapped(null);
document.removeEventListener("mouseup", handleMouseUp); document.removeEventListener("mouseup", handleMouseUp);
document.removeEventListener("mousemove", handleMouseMove); document.removeEventListener("mousemove", handleMouseMove);
draggingRemovedRef.current = false; draggingRemovedRef.current = false;