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

Text selection on title don't work #276

Open
vovsemenv opened this issue Jul 5, 2023 · 3 comments
Open

Text selection on title don't work #276

vovsemenv opened this issue Jul 5, 2023 · 3 comments
Assignees

Comments

@vovsemenv
Copy link

vovsemenv commented Jul 5, 2023

For some reason, I can't start the text selection process on the tree item title. To select any text, i need to start selection outside of tree

code to reprodcue

import {
  StaticTreeDataProvider,
  Tree,
  UncontrolledTreeEnvironment,
} from "react-complex-tree";
import "react-complex-tree/lib/style-modern.css";

export const App = () => {
  const items = {
    root: {
      index: "root",
      isFolder: true,
      children: ["child1", "child2"],
      data: "Root item",
    },
    child1: {
      index: "child1",
      children: [],
      data: "Very long test case",
    },
    child2: {
      index: "child2",
      isFolder: true,
      children: ["child3"],
      data: "Child item 2",
    },
    child3: {
      index: "child3",
      children: [],
      data: "Child item 3",
    },
  };

  return (
    <UncontrolledTreeEnvironment
      dataProvider={
        new StaticTreeDataProvider(items, (item, data) => ({ ...item, data }))
      }
      getItemTitle={(item) => item.data}
      viewState={{}}
    >
      <Tree treeId="tree-1" rootItem="root" treeLabel="Tree Example" />
    </UncontrolledTreeEnvironment>
  );
};
@lukasbach
Copy link
Owner

Hi, thanks for your report! The tree node DOM items are provided with a "draggable" attribute, which means that clicking with the mouse an them and dragging, which is usually the behavior for selecting text, will drag the entire item instead, and surpress the text selection that would otherwise happen on the text within the item. In general, supporting both manually selecting text in an elemnent and also supporting to drag that item won't work, in any browser. Or am I misunderstanding the issue?

@vovsemenv
Copy link
Author

You understand it correctly. Maybe there is a way to change drag handle selector so i can drag item by cliching on it instead of whole item?

@lukasbach
Copy link
Owner

Hm, I'd say your best bet is to use a custom interaction manager implementation, that allows you to customize the props provided to the interactive element, there you can write the logic of how the interactive element is rendered yourself: https://rct.lukasbach.com/docs/guides/interaction-modes#custom-interaction-modes

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

2 participants