Skip to content

Commit

Permalink
[3100] Add support for drop on IconLabelNode
Browse files Browse the repository at this point in the history
Bug: #3100
Signed-off-by: Florian ROUËNÉ <florian.rouene@obeosoft.com>
  • Loading branch information
frouene committed Feb 14, 2024
1 parent 211a3b5 commit 0fe5fa9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Expand Up @@ -64,6 +64,7 @@ This changes a core assumption from before where an element known to those servi
- https://github.com/eclipse-sirius/sirius-web/issues/2823[#2823] [diagram] Fix an issue that prevents nodes from being resized smaller than their default size.
- https://github.com/eclipse-sirius/sirius-web/issues/3063[#3063] [selection] Ensure Selections are always refreshed using the _current_ version of their target element
- https://github.com/eclipse-sirius/sirius-web/issues/2721[#2721] [diagram] Prevent labels to exceed their container
- https://github.com/eclipse-sirius/sirius-web/issues/3100[#3100] [diagram] Add support for drop on `IconLabelNode`

=== New Features

Expand Down
Expand Up @@ -20,6 +20,7 @@ import { DiagramElementPalette } from '../palette/DiagramElementPalette';
import { IconLabelNodeData } from './IconsLabelNode.types';
import { NodeContext } from './NodeContext';
import { NodeContextValue } from './NodeContext.types';
import { useDrop } from '../drop/useDrop';

const iconlabelStyle = (
style: React.CSSProperties,
Expand All @@ -42,15 +43,23 @@ const iconlabelStyle = (

export const IconLabelNode = memo(({ data, id, selected }: NodeProps<IconLabelNodeData>) => {
const theme = useTheme();
const { onDrop, onDragOver } = useDrop();
const { style: dropFeedbackStyle } = useDropNodeStyle(id);
const { hoveredNode } = useContext<NodeContextValue>(NodeContext);

const handleOnDrop = (event: React.DragEvent) => {
onDrop(event, id);
};

return (
<div style={{ paddingLeft: '8px', paddingRight: '8px' }}>
<div
style={{
...iconlabelStyle(data.style, theme, selected, hoveredNode?.id === id, data.faded),
...dropFeedbackStyle,
}}
onDragOver={onDragOver}
onDrop={handleOnDrop}
data-testid={`IconLabel - ${data?.insideLabel?.text}`}>
{data.insideLabel ? (
<Label diagramElementId={id} label={data.insideLabel} faded={data.faded} transform="" />
Expand Down

0 comments on commit 0fe5fa9

Please sign in to comment.