From de22a0f33875f886763ffae54e59b0618be49cab Mon Sep 17 00:00:00 2001 From: Mikyung Kim Date: Thu, 19 Dec 2024 15:22:47 +0900 Subject: [PATCH] WRR-8543: Fixed editable `Scroller` not to use static classname (#1767) * WRR-8543: Fixed Editable Scroller not to use static classname Enact-DCO-1.0-Signed-off-by: Mikyung Kim (mikyung27.kim@lge.com) * Added a guard Enact-DCO-1.0-Signed-off-by: Mikyung Kim (mikyung27.kim@lge.com) --- Scroller/EditableWrapper.js | 8 ++++---- samples/sampler/stories/qa/IconItem.js | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Scroller/EditableWrapper.js b/Scroller/EditableWrapper.js index 6982c671da..b567eeeeca 100644 --- a/Scroller/EditableWrapper.js +++ b/Scroller/EditableWrapper.js @@ -268,7 +268,7 @@ const EditableWrapper = (props) => { }, [customCss.focused, findItemNode]); const handleClickCapture = useCallback((ev) => { - if (ev.target.className.includes('Button')) { + if (ev.target?.parentNode?.parentNode.getAttribute('role') === 'button') { return; } // Consume the event to prevent Item behavior @@ -280,7 +280,7 @@ const EditableWrapper = (props) => { }, []); const handleMouseDown = useCallback((ev) => { - if (ev.target.className.includes('Button')) { + if (ev.target?.parentNode?.parentNode.getAttribute('role') === 'button') { return; } if (mutableRef.current.selectedItem) { @@ -732,7 +732,7 @@ const EditableWrapper = (props) => { ev.preventDefault(); } - if (mutableRef.current.isDraggingItem && !ev.target.className.includes('Button')) { + if (mutableRef.current.isDraggingItem && ev.target?.parentNode?.parentNode.getAttribute('role') !== 'button') { const {clientX} = ev.targetTouches[0]; mutableRef.current.lastMouseClientX = clientX; @@ -755,7 +755,7 @@ const EditableWrapper = (props) => { const {clientX} = ev.changedTouches[0]; const targetItemIndex = getNextIndexFromPosition(clientX, 0); - if (ev.target.className.includes('Button') && Number(selectedItem?.style.order) - 1 === targetItemIndex) { + if (ev.target?.parentNode?.parentNode.getAttribute('role') === 'button' && Number(selectedItem?.style.order) - 1 === targetItemIndex) { return; } diff --git a/samples/sampler/stories/qa/IconItem.js b/samples/sampler/stories/qa/IconItem.js index f5937f7d84..fedaf16731 100644 --- a/samples/sampler/stories/qa/IconItem.js +++ b/samples/sampler/stories/qa/IconItem.js @@ -160,7 +160,7 @@ export const EditableIcon = (args) => { }, [setEditMode]); const handleMouseDown = useCallback((ev) => { - if (!ev.target.className.includes('Button')) { + if (ev.target?.parentNode?.parentNode.getAttribute('role') !== 'button') { const targetItemNode = findItemNode(ev.target); if (targetItemNode && targetItemNode.style.order) { mutableRef.current.initialSelected.itemIndex = targetItemNode.style.order;