Fixes table header (#1087)

* Wrap up Front chat

* Wrap up Front chat

* Disable entity selectionwhen starting from menu
This commit is contained in:
Charles Bochet
2023-08-04 19:27:48 -07:00
committed by GitHub
parent 6008789a17
commit 1bf44e0188
4 changed files with 17 additions and 12 deletions

View File

@ -1,51 +0,0 @@
import { RefObject } from 'react';
import {
boxesIntersect,
useSelectionContainer,
} from '@air/react-drag-to-select';
type OwnProps = {
dragSelectable: RefObject<HTMLElement>;
onDragSelectionChange: (id: string, selected: boolean) => void;
onDragSelectionStart: () => void;
};
export function DragSelect({
dragSelectable,
onDragSelectionChange,
onDragSelectionStart,
}: OwnProps) {
const { DragSelection } = useSelectionContainer({
onSelectionStart: onDragSelectionStart,
onSelectionChange: (box) => {
const scrollAwareBox = {
...box,
top: box.top + window.scrollY,
left: box.left + window.scrollX,
};
Array.from(
dragSelectable.current?.querySelectorAll('[data-selectable-id]') ?? [],
).forEach((item) => {
const id = item.getAttribute('data-selectable-id');
if (!id) {
return;
}
if (boxesIntersect(scrollAwareBox, item.getBoundingClientRect())) {
onDragSelectionChange(id, true);
} else {
onDragSelectionChange(id, false);
}
});
},
selectionProps: {
style: {
border: '1px solid #4C85D8',
background: 'rgba(155, 193, 239, 0.4)',
position: `absolute`,
zIndex: 99,
},
},
});
return <DragSelection />;
}