mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
Fix sortable component as the sort order was broken.
This commit is contained in:
parent
509989279b
commit
53740fc57a
@ -1,6 +1,5 @@
|
|||||||
import type { Meta, StoryObj } from "@storybook/react";
|
import type { Meta, StoryObj } from "@storybook/react";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { Draggable } from "./draggable";
|
|
||||||
import { Sortable } from "./sortable";
|
import { Sortable } from "./sortable";
|
||||||
|
|
||||||
const meta: Meta<typeof Sortable> = {
|
const meta: Meta<typeof Sortable> = {
|
||||||
@ -13,7 +12,7 @@ type Story = StoryObj<typeof Sortable>;
|
|||||||
|
|
||||||
const data = [
|
const data = [
|
||||||
{ id: "1", name: "John Doe" },
|
{ id: "1", name: "John Doe" },
|
||||||
{ id: "2", name: "Jane Doe 2" },
|
{ id: "2", name: "Satish" },
|
||||||
{ id: "3", name: "Alice" },
|
{ id: "3", name: "Alice" },
|
||||||
{ id: "4", name: "Bob" },
|
{ id: "4", name: "Bob" },
|
||||||
{ id: "5", name: "Charlie" },
|
{ id: "5", name: "Charlie" },
|
||||||
|
@ -17,7 +17,7 @@ const moveItem = <T,>(
|
|||||||
destination: T & Record<symbol, string>,
|
destination: T & Record<symbol, string>,
|
||||||
keyExtractor: (item: T, index: number) => string
|
keyExtractor: (item: T, index: number) => string
|
||||||
) => {
|
) => {
|
||||||
const sourceIndex = data.indexOf(source);
|
const sourceIndex = data.findIndex((item, index) => keyExtractor(item, index) === keyExtractor(source, 0));
|
||||||
if (sourceIndex === -1) return data;
|
if (sourceIndex === -1) return data;
|
||||||
|
|
||||||
const destinationIndex = data.findIndex((item, index) => keyExtractor(item, index) === keyExtractor(destination, 0));
|
const destinationIndex = data.findIndex((item, index) => keyExtractor(item, index) === keyExtractor(destination, 0));
|
||||||
|
Loading…
Reference in New Issue
Block a user