Skip to content

Commit

Permalink
Merge pull request #336 from visdesignlab/column-highlight-removal
Browse files Browse the repository at this point in the history
Update column highlight to remove on mouse leave
  • Loading branch information
JakeWags authored Apr 2, 2024
2 parents 6d06f8f + e281f65 commit 9943aa8
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 13 deletions.
11 changes: 0 additions & 11 deletions packages/upset/src/components/Root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { columnsAtom } from '../atoms/columnAtom';
import { itemsAtom } from '../atoms/itemsAtoms';
import { setsAtom } from '../atoms/setsAtoms';
import { dataAtom } from '../atoms/dataAtom';
import { columnHoverAtom } from '../atoms/highlightAtom';
import { contextMenuAtom } from '../atoms/contextMenuAtom';
import { upsetConfigAtom } from '../atoms/config/upsetConfigAtoms';
import {
Expand Down Expand Up @@ -65,7 +64,6 @@ export const Root: FC<Props> = ({

const [sets, setSets] = useRecoilState(setsAtom);
const [items, setItems] = useRecoilState(itemsAtom);
const [columnHover, setColumnHover] = useRecoilState(columnHoverAtom);
const setAttributeColumns = useSetRecoilState(attributeAtom);
const setAllColumns = useSetRecoilState(columnsAtom);
const setData = useSetRecoilState(dataAtom);
Expand Down Expand Up @@ -103,24 +101,15 @@ export const Root: FC<Props> = ({
setData(data);
}, [data]);

// remove column hover state
const removeHover = () => {
if (columnHover.length > 0) {
setColumnHover([]);
}
};

// close all open context menus
const removeContextMenu = () => {
setContextMenu(null);
};

useEffect(() => {
document.addEventListener('contextmenu', removeContextMenu, false);
document.addEventListener('mousemove', removeHover, false);

return function removeListeners() {
document.removeEventListener('mousemove', removeHover, false);
document.removeEventListener('contextmenu', removeContextMenu, false);
};
}, []);
Expand Down
1 change: 0 additions & 1 deletion packages/upset/src/components/Rows/AggregateRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ export const AggregateRow: FC<Props> = ({ aggregateRow }) => {

return (
<g
onMouseMove={(e) => e.stopPropagation()}
onClick={() => aggregateRow && (setCurrentIntersectionAtom(aggregateRow))}
css={mousePointer}
>
Expand Down
2 changes: 1 addition & 1 deletion packages/upset/src/components/Rows/SubsetRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export const SubsetRow: FC<Props> = ({ subset }) => {

return (
<g
onMouseMove={(e) => e.stopPropagation()}
onClick={
() => {
if (currentIntersection !== null && currentIntersection.id === subset.id) { // if the row is already selected, deselect it
Expand All @@ -56,6 +55,7 @@ export const SubsetRow: FC<Props> = ({ subset }) => {
}
onMouseLeave={() => {
setHover(null);
setColumnHighlight([]);
}}
css={mousePointer}
>
Expand Down

0 comments on commit 9943aa8

Please sign in to comment.