introduced designer id, bring to front

This commit is contained in:
Jan Prochazka
2020-12-26 10:28:49 +01:00
parent 54bdaac64f
commit 95e0905f01
3 changed files with 41 additions and 19 deletions

View File

@@ -23,7 +23,7 @@ const ColumnsWrapper = styled.div`
`;
export default function DesignerTable(props) {
const { pureName, columns, left, top, onChangeTable, index } = props;
const { pureName, columns, left, top, onChangeTable, onBringToFront } = props;
const [movingPosition, setMovingPosition] = React.useState(null);
const movingPositionRef = React.useRef(null);
@@ -54,14 +54,11 @@ export default function DesignerTable(props) {
const handleMoveEnd = React.useCallback(
(e) => {
if (movingPositionRef.current) {
onChangeTable(
{
...props,
left: movingPositionRef.current.left,
top: movingPositionRef.current.top,
},
index
);
onChangeTable({
...props,
left: movingPositionRef.current.left,
top: movingPositionRef.current.top,
});
}
movingPositionRef.current = null;
@@ -71,7 +68,7 @@ export default function DesignerTable(props) {
// this.props.designer.changedModel(true);
},
[onChangeTable, index]
[onChangeTable, props]
);
React.useEffect(() => {
@@ -103,6 +100,7 @@ export default function DesignerTable(props) {
left: movingPosition ? movingPosition.left : left,
top: movingPosition ? movingPosition.top : top,
}}
onMouseDown={() => onBringToFront(props)}
>
<Header onMouseDown={headerMouseDown}>{pureName}</Header>
<ColumnsWrapper>