Skip to content

Commit 9192d68

Browse files
Disable dragging when search text is active
Signed-off-by: Adhitya Mamallan <adhitya.mamallan@uber.com>
1 parent fb20ed5 commit 9192d68

File tree

2 files changed

+40
-6
lines changed

2 files changed

+40
-6
lines changed

src/views/shared/workflows-list-columns-picker/workflows-list-columns-picker.styles.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ export const styled = {
5858
width: '100%',
5959
gap: $theme.sizing.scale300,
6060
})),
61+
CheckboxContainer: createStyled('div', {
62+
pointerEvents: 'all',
63+
}),
6164
ColumnName: createStyled('span', ({ $theme }: { $theme: Theme }) => ({
6265
...$theme.typography.ParagraphSmall,
6366
display: 'flex',
@@ -136,4 +139,23 @@ export const overrides = {
136139
}),
137140
},
138141
} satisfies ListOverrides,
142+
dndListDragDisabled: {
143+
DragHandle: {
144+
style: (): StyleObject => ({
145+
opacity: 0.3,
146+
pointerEvents: 'none',
147+
cursor: 'default',
148+
}),
149+
},
150+
Item: {
151+
style: (): StyleObject => ({
152+
cursor: 'default',
153+
pointerEvents: 'none',
154+
':hover': {
155+
borderColor: 'transparent',
156+
backgroundColor: 'inherit',
157+
},
158+
}),
159+
},
160+
} satisfies ListOverrides,
139161
};

src/views/shared/workflows-list-columns-picker/workflows-list-columns-picker.tsx

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { useCallback, useMemo, useState } from 'react';
33
import { Button } from 'baseui/button';
44
import { Checkbox } from 'baseui/checkbox';
55
import { List, arrayMove } from 'baseui/dnd-list';
6+
import { mergeOverrides } from 'baseui/helpers/overrides';
67
import { Input } from 'baseui/input';
78
import { Popover } from 'baseui/popover';
89
import { MdArrowDropDown, MdArrowDropUp, MdTune } from 'react-icons/md';
@@ -84,6 +85,8 @@ export default function WorkflowsListColumnsPicker({
8485
setIsOpen(false);
8586
}, [onApply, columns]);
8687

88+
const isDragDisabled = searchQuery.length > 0;
89+
8790
const handleDragEnd = useCallback(
8891
({ oldIndex, newIndex }: { oldIndex: number; newIndex: number }) => {
8992
if (newIndex === -1 || searchQuery.length > 0) return;
@@ -123,22 +126,31 @@ export default function WorkflowsListColumnsPicker({
123126
<styled.ColumnName>
124127
{col?.name ?? entry.id}
125128
</styled.ColumnName>
126-
<div
127-
onClick={(e) => e.stopPropagation()}
128-
onMouseDown={(e) => e.stopPropagation()}
129-
onTouchStart={(e) => e.stopPropagation()}
129+
<styled.CheckboxContainer
130+
onClick={(e: React.MouseEvent) => e.stopPropagation()}
131+
onMouseDown={(e: React.MouseEvent) => e.stopPropagation()}
132+
onTouchStart={(e: React.TouchEvent) =>
133+
e.stopPropagation()
134+
}
130135
>
131136
<Checkbox
132137
checked={entry.checked}
133138
onChange={() => handleToggle(entry.id)}
134139
checkmarkType="toggle"
135140
/>
136-
</div>
141+
</styled.CheckboxContainer>
137142
</styled.ColumnRow>
138143
);
139144
})}
140145
onChange={handleDragEnd}
141-
overrides={overrides.dndList}
146+
overrides={
147+
isDragDisabled
148+
? mergeOverrides(
149+
overrides.dndList,
150+
overrides.dndListDragDisabled
151+
)
152+
: overrides.dndList
153+
}
142154
/>
143155
</styled.ColumnsList>
144156
<styled.Footer>

0 commit comments

Comments
 (0)