Skip to content

Commit b52ac09

Browse files
committed
fixed scrolling when reordering
1 parent 7b062b5 commit b52ac09

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

src/components/habit/card.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,13 @@ export const HabitCard: React.FC = () => {
5757

5858
if (!matchActiveTags(habit, tags.active)) return null
5959

60-
const extraProps = isReordering
61-
? { ref: setNodeRef, style, ...attributes, ...listeners }
62-
: undefined
60+
const extraProps = isReordering ? { ref: setNodeRef, style, ...attributes } : undefined
6361

6462
return (
6563
<div
6664
{...extraProps}
6765
className={cn(
68-
"habit-card rounded truncate w-full max-w-211 flex flex-col gap-1 touch-none",
66+
"habit-card rounded truncate w-full max-w-211 flex flex-col gap-1",
6967
{
7068
"min-h-40": !displayOptions.hideChart,
7169
},
@@ -86,7 +84,7 @@ export const HabitCard: React.FC = () => {
8684
<div className={cn("flex items-center gap-1 w-full px-2 pl-3 min-h-11")}>
8785
<LinkWrapper>
8886
<div className="flex items-center gap-3 grow">
89-
<HabitIcon size={20} className="w-6" />
87+
<HabitIcon size={20} className="w-6 touch-none" {...listeners} />
9088

9189
<div className="flex flex-col gap-0">
9290
<span

src/components/ordering/provider.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export const OrderingProvider: React.FC<React.PropsWithChildren> = ({ children }
7979

8080
React.useEffect(() => {
8181
setOrderedNames(reorder(habits, completed, collection.order, isReordering))
82-
}, [completed])
82+
}, [completed, habits])
8383

8484
const handleDragEnd = (event: DragEndEvent) => {
8585
const { active, over } = event

src/lib/queries.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,12 +238,14 @@ const usePushHabit = () => {
238238
export const useNewHabit = () => {
239239
const repo = useRepoContext()
240240
const pushHabit = usePushHabit()
241+
const invalidateCollection = useInvalidateCollection()
241242

242243
return useMutation({
243244
mutationFn: (habit: Habit) => pushHabit(`start new habit - "${habit.name}"`, habit),
244245

245246
onSettled: async () => {
246247
await client.invalidateQueries({ queryKey: ["repo", repo.id, "content"] })
248+
await invalidateCollection()
247249
},
248250
retry: handleError("Failed to start a habit", { maxFailures: 0 }),
249251
})

0 commit comments

Comments
 (0)