Skip to content

Commit 462a89a

Browse files
committed
comments &sonar issue resolved
1 parent 3823062 commit 462a89a

File tree

2 files changed

+21
-15
lines changed

2 files changed

+21
-15
lines changed

forms-flow-components/src/components/CustomComponents/DragandDropSort.tsx

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React, { useState, useEffect } from "react";
2-
import { FormVariableIcon,DraggableIcon } from "../SvgIcons/index";
2+
import { FormVariableIcon,DraggableIcon } from "../SvgIcons/index";
3+
import { StyleServices } from "@formsflow/service";
34

45
interface FilterItem {
56
label: string;
@@ -16,27 +17,27 @@ interface DragAndDropFilterProps {
1617

1718
export const DragandDropSort: React.FC<DragAndDropFilterProps> = ({ items, onUpdate }) => {
1819

19-
const computedStyle = getComputedStyle(document.documentElement);
20-
const darkColor = computedStyle.getPropertyValue("--ff-gray-darkest");
20+
const darkColor = StyleServices.getCSSVariable('--ff-gray-darkest');
21+
2122
const [filterItems, setFilterItems] = useState<FilterItem[]>(items);
2223
const [draggingIndex, setDraggingIndex] = useState<number | null>(null);
2324

2425
useEffect(() => {
2526
onUpdate(filterItems);
2627
}, [filterItems, onUpdate]);
2728

28-
const onDragStart = (e: React.DragEvent<HTMLDivElement>, index: number) => {
29+
const onDragStart = (e: React.DragEvent<HTMLLIElement>, index: number) => {
2930
e.stopPropagation();
3031
e.dataTransfer.setData("drag-index", index.toString());
3132
setDraggingIndex(index);
3233
};
3334

34-
const onDragOver = (e: React.DragEvent<HTMLDivElement>) => {
35+
const onDragOver = (e: React.DragEvent<HTMLLIElement>) => {
3536
e.preventDefault();
3637
};
3738

3839

39-
const onDragEnter = (e: React.DragEvent<HTMLDivElement>, targetIndex: number) => {
40+
const onDragEnter = (e: React.DragEvent<HTMLLIElement>, targetIndex: number) => {
4041
e.preventDefault();
4142
if (draggingIndex === null || draggingIndex === targetIndex) return;
4243

@@ -49,7 +50,7 @@ export const DragandDropSort: React.FC<DragAndDropFilterProps> = ({ items, onUpd
4950
setDraggingIndex(targetIndex);
5051
};
5152

52-
const onDrop = (e: React.DragEvent<HTMLDivElement>) => {
53+
const onDrop = (e: React.DragEvent<HTMLLIElement>) => {
5354
e.preventDefault();
5455
setDraggingIndex(null);
5556
};
@@ -67,24 +68,26 @@ export const DragandDropSort: React.FC<DragAndDropFilterProps> = ({ items, onUpd
6768
};
6869
return (
6970
<div className="drag-drop-container">
70-
{filterItems.map((item, index) => (
71-
<div
71+
<ul>
72+
{filterItems.map((item, index) => (
73+
<li
7274
key={item.name}
75+
draggable
7376
className={`draggable-item ${draggingIndex === index ? "dragging" : ""} `}
7477
onDragOver={onDragOver}
7578
onDrop={onDrop}
7679
onDragEnter={(e) => onDragEnter(e, index)}
7780
onDragEnd={onDragEnd}
81+
onDragStart={(e) => onDragStart(e, index)}
7882
>
79-
<div
80-
draggable
83+
<span
8184
className="draggable-icon"
82-
onDragStart={(e) => onDragStart(e, index)}
8385
>
8486
<DraggableIcon />
85-
</div>
87+
</span>
8688
<div className="checkbox-container">
8789
<input
90+
data-testid={`${item.name}-checkbox`}
8891
type="checkbox"
8992
className="form-check-input"
9093
checked={item.isChecked}
@@ -96,8 +99,9 @@ export const DragandDropSort: React.FC<DragAndDropFilterProps> = ({ items, onUpd
9699
{item.isTaskVariable && (
97100
<FormVariableIcon color={darkColor} />
98101
) }
99-
</div>
102+
</li>
100103
))}
104+
</ul>
101105
</div>
102106
);
103107
};

forms-flow-theme/scss/_modal.scss

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1002,7 +1002,7 @@ $black-color: var(--ff-black);
10021002
align-items: center;
10031003
gap: var(--spacer-100);
10041004
border-radius: var(--radius-sm);
1005-
padding: 0px var(--spacer-050) ;
1005+
padding: var(--spacer-050) ;
10061006
transition:
10071007
transform 3s cubic-bezier(0.25, 1, 0.5, 1),
10081008
background-color 3s ease-in-out,
@@ -1020,6 +1020,8 @@ $black-color: var(--ff-black);
10201020

10211021
&.dragging {
10221022
background-color: $gray-medium;
1023+
opacity: 1;
1024+
z-index: 1000;
10231025
transform: scale(1.03);
10241026
}
10251027
.checkbox-container{

0 commit comments

Comments
 (0)