-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[tree view] Unable to use input in TreeItem #12629
Comments
This comment has been minimized.
This comment has been minimized.
I don't think that it's a use case we really want to support. However, I guess we could play nicely with it. I see 3 options:
@joshwooding Do you have a preference? I'm leaning toward 2. |
I had the same though initially but the problem is (as usual) portals. Having a dialog open from a tree is reasonable IMO. For keyboard events I'm usually in favor of checking for |
Yeah contentEditable is something that I always forget. Same applies to listitems (e.g. an editable TODO-list). |
I’m happy with 2. It was the first solution I thought of |
So I guess something like this would do it: diff --git a/packages/material-ui-lab/src/TreeItem/TreeItem.js b/packages/material-ui-lab/src/TreeItem/TreeItem.js
index ae7be28ae..2066db063 100644
--- a/packages/material-ui-lab/src/TreeItem/TreeItem.js
+++ b/packages/material-ui-lab/src/TreeItem/TreeItem.js
@@ -150,7 +150,7 @@ const TreeItem = React.forwardRef(function TreeItem(props, ref) {
let flag = false;
const key = event.key;
- if (event.altKey || event.ctrlKey || event.metaKey) {
+ if (event.altKey || event.ctrlKey || event.metaKey || event.currentTarget !== event.target) {
return;
}
if (event.shift) { @kenianbei Do you want to work on a pull request? |
When embedding an input or textfield in a TreeItem, user is unable to type anything other than space, backspace, delete, but no characters. However pasting does work. Also inputs do work within TreeView, but not TreeItem.
See: https://codesandbox.io/s/long-fire-csg6f?fontsize=14&hidenavigation=1&theme=dark
Current Behavior 😯
When embedding an input or textfield in a TreeItem, user is unable to type anything other than space, backspace, delete, but no characters. However pasting does work.
Expected Behavior 🤔
We should be able to have inputs or Textfield as children of TreeItem.
Steps to Reproduce 🕹
See: https://codesandbox.io/s/long-fire-csg6f?fontsize=14&hidenavigation=1&theme=dark
Context 🔦
Actually my context is that I have a Dialog within the TreeItem, and when it is opened it is still affected by this issue, since it is still nested within the TreeItem. If it isn't able to be fixed I will move the Dialog outside the TreeItem and use redux state to open the dialog.
Your Environment 🌎
Search keywords:
The text was updated successfully, but these errors were encountered: