Skip to content

Commit

Permalink
WRR-8543: Fixed editable Scroller not to use static classname (#1767)
Browse files Browse the repository at this point in the history
* 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)
  • Loading branch information
MikyungKim authored Dec 19, 2024
1 parent 7ec3f80 commit de22a0f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions Scroller/EditableWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) {
Expand Down Expand Up @@ -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;

Expand All @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion samples/sampler/stories/qa/IconItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit de22a0f

Please sign in to comment.