Uploaded image for project: 'Camunda Optimize'
  1. Camunda Optimize
  2. OPT-1114

Cannot remove values in the Add Variable Filter modal

    • Icon: Bug Report Bug Report
    • Resolution: Fixed
    • Icon: L3 - Default L3 - Default
    • 2.0.0
    • None
    • frontend
    • None

      AT:

      • in the variable filter for numeric variables:
        • if I have just one input field, it is not possible to remove it
        • if I have more than just one input field, I can remove any of them by clicking on an x button next to the input fields
        • the add value button is always shown

      Context:

      • Given
        • Open the Add Variable Filter modal
        • Enter two values
      • When
        • I delete one variable value (because I've entered the value by accident)
      • Then
        • the corresponding value input field is still existing and expects a value
      • Problem
        • It is not possible to continue after removing a variable

      The same problem appears when I select 'Add Value' by accident. The filter expects that I enter a new value. There is no chance to undo this action.

        This is the controller panel for Smart Panels app

            [OPT-1114] Cannot remove values in the Add Variable Filter modal

            I could not find any commits related to this issue.

            Sebastian Stamm added a comment - I could not find any commits related to this issue.

            Do not mutate state. I would recommend using filter instead of splice.

            Sebastian Stamm added a comment - Do not mutate state . I would recommend using filter instead of splice .

            Johannes added a comment -

            I did not use filter because this would throw out all input elements with the same value as the one I want to remove.

            Johannes added a comment - I did not use filter because this would throw out all input elements with the same value as the one I want to remove.

            The code is okay, just FYI: The filter function gets a second argument which is the index of the element. So lines 416 - 420 can be replaced with

            return {
              values: prevState.values.filter((_, idx) => idx !== index)
            }
            

            That would avoid removing all elements based on the value. It would be even more readable if the index variable would be renamed to indexToRemove. Feel free to use either your solution or the filter variant.

            Sebastian Stamm added a comment - The code is okay, just FYI: The filter function gets a second argument which is the index of the element. So lines 416 - 420 can be replaced with return { values: prevState.values.filter((_, idx) => idx !== index) } That would avoid removing all elements based on the value. It would be even more readable if the index variable would be renamed to indexToRemove . Feel free to use either your solution or the filter variant.

            Johannes added a comment -

            Okay, didn't know that the filter function also provides the index. Of course that is a lot nicer. I'll change that.

            Johannes added a comment - Okay, didn't know that the filter function also provides the index. Of course that is a lot nicer. I'll change that.

              Unassigned Unassigned
              michael.schoettes Michael Schoettes
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: