leva icon indicating copy to clipboard operation
leva copied to clipboard

Bug in the Button get function causing getting undefined, when Folder is used.

Open y-he2 opened this issue 2 years ago • 2 comments

In this.get in the Button codes, which is calling this.getInput, which in turn relying on this.getData()[path]. When Folder is used for that useControls group, the actual "path" in this.getData() reads: "FolderName.VariableName" instead of only VariableName. Which will result in getting undefined if the FolderName string (include spaces) is not included in the "Button ... get( here )". So my suggestion is either improve the definition of "path" or improve the documentation to require including FolderName (include space) when use Button, get, with Folder feature.

y-he2 avatar May 17 '22 13:05 y-he2

You can update the documentation. We could upgrade get in the case of a button to be relative to the folder, meaning if you wanted to retrieve values outside the folder you would have to do:

useControls({
  myFolder1: folder({ value1: 0 }),
  myFolder2: folder({ button2: button((get) => get('../myFolder1/value1')) })
})

...but that would require a bit of rewrite.

dbismut avatar May 17 '22 16:05 dbismut

Maybe it was my misunderstanding about how the get should work. The problem with the current path is that if the folder name contains spaces then the getter would be used something like get( "folder name.VariableName" ). But as said that maybe intended.

I have not followed the project along the way, none the less its a beautiful project, as a successor in React to dat.gui. Could you point where would u recommend to update in the docs, as in where should the mechanism of the "Path" in the getter be explained?

y-he2 avatar May 18 '22 11:05 y-he2