rajalakshmys-27 commented on code in PR #3985:
URL: 
https://github.com/apache/incubator-kie-tools/pull/3985#discussion_r3881992236


##########
packages/dmn-editor/src/diagram/Palette.tsx:
##########
@@ -107,6 +135,130 @@ export function Palette({ pulse }: { pulse: boolean }) {
 
   const { maxHeight } = useInViewSelect(dmnEditorRootElementRef, 
nodesPalletePopoverRef);
 
+  const panelRef = useRef<HTMLDivElement>(null);
+  const paletteRef = useRef<HTMLDivElement>(null);
+  const submenuRef = useRef<HTMLDivElement>(null);
+  const iconMeasureRef = useRef<HTMLDivElement>(null);
+  const ellipsisButtonRef = useRef<HTMLButtonElement>(null);
+
+  const primaryIcons = useMemo(
+    () => [
+      { nodeType: NODE_TYPES.inputData as NodeType, title: 
i18n.nodes.inputData, className: "input-data" },
+      { nodeType: NODE_TYPES.decision as NodeType, title: i18n.nodes.decision, 
className: "decision" },
+      { nodeType: NODE_TYPES.bkm as NodeType, title: 
i18n.nodes.businessKnowledgeModel, className: "bkm" },
+      {
+        nodeType: NODE_TYPES.knowledgeSource as NodeType,
+        title: i18n.nodes.knowledgeSource,
+        className: "knowledge-source",
+      },
+      {
+        nodeType: NODE_TYPES.decisionService as NodeType,
+        title: i18n.nodes.decisionService,
+        className: "decision-service",
+      },
+    ],
+    [i18n]
+  );
+
+  const totalIcons = primaryIcons.length;
+  const [visibleIconCount, setVisibleIconCount] = useState<number>(totalIcons);
+  const [submenuOpen, setSubmenuOpen] = useState(false);
+
+  const showEllipsis = visibleIconCount < totalIcons;
+
+  const iconHeightRef = useRef(48);
+  const ellipsisHeightRef = useRef(40);
+
+  useEffect(() => {
+    if (iconMeasureRef.current) {
+      const rect = iconMeasureRef.current.getBoundingClientRect();
+      if (rect.height) {
+        iconHeightRef.current = rect.height;
+      }
+    }
+    if (ellipsisButtonRef.current) {
+      const rect = ellipsisButtonRef.current.getBoundingClientRect();
+      if (rect.height) {
+        ellipsisHeightRef.current = rect.height;
+      }
+    }
+  }, [visibleIconCount]);
+
+  useEffect(() => {
+    let animationFrameId: number | null = null;
+    let lastCount = totalIcons;
+
+    const updateVisibleIcons = () => {
+      if (animationFrameId !== null) cancelAnimationFrame(animationFrameId);
+
+      animationFrameId = requestAnimationFrame(() => {
+        if (!panelRef.current || !paletteRef.current) {
+          if (lastCount !== totalIcons) {
+            setVisibleIconCount(totalIcons);
+            lastCount = totalIcons;
+          }
+          return;
+        }
+
+        const newCount = calculateVisibleIconCount(
+          panelRef.current.getBoundingClientRect(),
+          paletteRef.current.getBoundingClientRect(),
+          window.innerHeight,
+          iconHeightRef.current,
+          ellipsisHeightRef.current,
+          totalIcons
+        );
+
+        if (newCount !== lastCount) {
+          setVisibleIconCount(newCount);
+          lastCount = newCount;
+        }
+      });
+    };
+
+    updateVisibleIcons();
+    window.addEventListener("resize", updateVisibleIcons);
+
+    return () => {
+      window.removeEventListener("resize", updateVisibleIcons);
+      if (animationFrameId !== null) cancelAnimationFrame(animationFrameId);
+    };
+  }, [totalIcons]);
+
+  const renderPaletteIcon = useCallback(

Review Comment:
   `renderPaletteIcon` is scoped to only the **5 primary DRG node icons** 
(Input Data, Decision, BKM, Knowledge Source, Decision Service) because those 
are the only ones that appear in the **overflow submenu** when the viewport is 
too small to show all of them.
   
   The other items are not grouped into submenu:
   
   - **Group & Text Annotation** — only 2 items in a fixed separate `<aside>`, 
always fully visible. Group also has a dedicated `onClick={groupNodes}` handler 
that drag-only icons don't have.
   - **DRG Nodes** — a panel toggle button that opens a `DrgNodesPanel` 
popover, not a draggable node icon.
   - **External Nodes** — same; a panel toggle button, not a draggable palette 
item.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to