leva icon indicating copy to clipboard operation
leva copied to clipboard

Does not filter/search by label

Open Glavin001 opened this issue 3 years ago • 1 comments

I notice when I use a label the filter does not work as expected and only filters based on the key.

For example: https://codesandbox.io/s/leva-3d-9i4h8

  • Key: repeat
  • Label: text. repeat
  const { ... } = useControls({
    shape: folder({
//...
      repeat: { value: [12, 3], label: 'text. repeat', joystick: false },
//...
    })
  })
Before filtering ✅ Filtering Key :x: Filtering Label
image image image

Solution

I think the applicable code is here: https://github.com/pmndrs/leva/blob/25747f423a8884f17c6fb4537cbfa53a3f87e100/packages/leva/src/components/Leva/tree.ts#L13

Used from here: https://github.com/pmndrs/leva/blob/25747f423a8884f17c6fb4537cbfa53a3f87e100/packages/leva/src/components/Leva/LevaRoot.tsx#L138


If this is not expected behaviour and others would also like fixed then I'd be happy to try to submit a PR 😃 Let me know!

Glavin001 avatar May 08 '22 08:05 Glavin001

You're totally right. Shouldn't be a big deal to fix in theory this but since label is in the settings you would need to fetch the settings for a given path and that might not be trivial to do this in that part of the code. You can have a shot at this if you feel like it, but another option would be to pass the filter as a context value and do the filter at the input level.

dbismut avatar May 08 '22 10:05 dbismut