-
Notifications
You must be signed in to change notification settings - Fork 717
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
Autocomplete variable parameter with the variable selected in the variable editor #6507
Conversation
); | ||
const variablePath = variableContext.lineage.map(variable => variable.name); | ||
variablePath.push(variableContext.name); | ||
return variablePath.join('.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this work with arrays?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, for array children, it does something like MyArray.3
. It's probably not what users want if they add an array and have one of its children selected, but I guess that's ok.
Do you think we should remove the child for these cases?
I guess, at some point, the field could choose according to the type of variable that is needed.
onSelectedVariableChange(nodes); | ||
} | ||
}, | ||
[onSelectedVariableChange, selectedNodes] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you really need to depend on selectedNodes
? This means any state change will also change all the callbacks using setSelectedNodes
. Previously, this was a stable function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try this instead:
const [selectedNodes, doSetSelectedNodes] = React.useState<Array<string>>([]);
const setSelectedNodes = React.useCallback(
(nodes: Array<string> | ((nodes: Array<string>) => Array<string>)) => {
// Use the functional update form to access the current state directly
doSetSelectedNodes(currentSelectedNodes => {
const newNodes = Array.isArray(nodes) ? nodes : nodes(currentSelectedNodes);
if (onSelectedVariableChange) {
onSelectedVariableChange(newNodes);
}
return newNodes;
});
},
[onSelectedVariableChange] // Remove selectedNodes from dependencies
);
Hmmm... Is this decision based on user research? Personally I find myself using strings more often than numbers, and to prefer strings as a default, since I can still write a number in there, then change the type. I personally do not find myself always going through the fields I configure from left to right/top to bottom, but to jump ahead then back depending to fill in fields I assume I might forget first, and the value I settled on setting the variable to is something I am more likely to forget than they type I want to give the variable. In fact I never was frustrated by the default type being a string, but am very often irritated by Arrays children not being strings by default.... |
Looking at examples, games mostly use number variables. Strings are usually directly set on text objects. I guess that strings variable are mostly used for the state of FSM. Could it be that you often work on network related features which probably requires things like string id?
Good new for you, arrays now use the previous child type. |
These changes has already be merged by: |
Also: