Skip to content

onChange fn in folder item makes the item dissapears in get #447

Description

@marospekarik

When I use the onChange function in an item in a folder, it will become unavailable in the get function.

This is the example when adding the onChange function to the item in a folder makes the slicerEnabled element unavailable in the get function. Therefore: get('slicerEnabled'); will fail.

  • When I remove the onChange function, I can retrieve the item with get
  • When I move the item outside of the folder, I can retrieve it with get
const [{...controls}, set, get]  = useControls( () => ({
         "Boundary Conditions": folder({
           inlet: { 
             value: 1.5,
             min: 0.1,
             max: 10,
             parameterized: true 
           },
           outlet: { value: true, parameterized: true },
         }, { collapsed: false }, ),
         "view": folder({
           viewModeSelect: {
             label: "View Mode",
             options: {
               "Point Cloud": 'PointCloud', 
               "Vector Fields": 'VectorFields',
               "Surface Slices": 'SurfaceSlices',
               "Streamline Slices": 'StreamlineSlices',
             }
           },
           slicerEnabled: {
             label: "Enable Slicer",
             value: false,
             parameterized: true,
             onChange: (v) => setSlicerMode(v)
           },
           slicerVal: {
             label: "Slice Y",
             value: 1.5,
             min: 0.1,
             max: 10,
             parameterized: true,
             onChange: (v) => {
                 const isSlicerEnabled = get('slicerEnabled');
                 if(!isSlicerEnabled) {
                    ... do my stufff 
                 }
             }
             render: (get) => get('view.slicerEnabled') == true,
           },

**ERROR:**
`Argument of type '"slicerEnabled"' is not assignable to parameter of type '"inlet" | "outlet" | "inlet_velocity" | "viewModeSelect" | "pointCloudSelect" | "pointCount" | "Message From PS"'.`

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingtypes

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions