Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Input inside of draggable element is break #118

Open
carlosvaldesweb opened this issue Nov 28, 2024 · 3 comments
Open

Input inside of draggable element is break #118

carlosvaldesweb opened this issue Nov 28, 2024 · 3 comments
Assignees

Comments

@carlosvaldesweb
Copy link

If you try to write space, input is broke.

Reproduction:
https://codesandbox.io/p/sandbox/drag-ndrop-kit-forked-83wtw7?file=%2Fsrc%2FApp.tsx%3A1%2C10-1%2C24

@sashamilenkovic sashamilenkovic self-assigned this Nov 29, 2024
@BradDuns
Copy link

BradDuns commented Dec 3, 2024

This is the error I see in the console:

Warning: You provided a `value` prop to a form field without an `onChange` handler. 
This will render a read-only field. If the field should be mutable use `defaultValue`. 
Otherwise, set either `onChange` or `readOnly`.

If I modify to add a change handler to the reproduction it seems to work.
Do you have an onChange handler in your other code?

@miguel-martinr
Copy link

miguel-martinr commented Dec 7, 2024

I'm having a similar issue. Text Inputs and textarea won't fire onChange when entering a white space. I can't move the text cursor either using the arrows or clicking.

My setup:

export const QueueItemList = ({ items }: QueueItemListProps) => {
  const handleDragEnd = () => {
    setQueueItems(
      queueItems.map((item, index) => ({ ...item, priority: index + 1 }))
    );
  };

  const [parentRef, queueItems, setQueueItems, updateConfig] = useDragAndDrop<
    HTMLDivElement,
    QueueItemCardProps
  >(items, {
    sortable: true,
    plugins: [animations()],
    onDragend: handleDragEnd,
  });

  return (
    <div ref={parentRef} className={styles.itemList}>
      {queueItems.map((queueItem, index) => {
        return (
          <li key={queueItem.title + index}>
            <QueueItemCard {...queueItem} />
          </li>
        );
      })}
    </div>
  );
};

Where QueueItemCard renders a text input and a textarea

@laakal
Copy link

laakal commented Dec 17, 2024

I solved the problem by using react portal for interactive elements. But it is not maintainable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants