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 in renderItemTitle can not work #421

Open
chenyingkeai opened this issue Dec 6, 2024 · 1 comment
Open

input in renderItemTitle can not work #421

chenyingkeai opened this issue Dec 6, 2024 · 1 comment
Assignees

Comments

@chenyingkeai
Copy link

I want my controlled tree to show the input box in a certain situation and input can be made, but I found that when using the input in renderItemTitle, it can't even focus, here is a simple example, is there any way to solve it?thank you
https://codesandbox.io/p/sandbox/react-complex-tree-playground-memo-demo-forked-9zpsmf

@lukasbach
Copy link
Owner

Have a look at the default implementation of renderItem: https://github.com/lukasbach/react-complex-tree/blob/main/packages/core/src/renderers/createDefaultRenderers.tsx#L89

If an item is being renamed, the item is rendered as a div. Otherwise, it is rendered as button by default. By manually inserting an input within the item container which renders as button, the button claims all input events, and this will also create invalid semantic structure. You can probably get it to work by adjusting the renderItem method to make the content of the title not being rendered as part of a button element as long as it contains an input.

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