Skip to content
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

Ability to Reset Selected Field Value to Empty #6012

Closed
Bonapara opened this issue Jun 25, 2024 · 4 comments · May be fixed by #6040
Closed

Ability to Reset Selected Field Value to Empty #6012

Bonapara opened this issue Jun 25, 2024 · 4 comments · May be fixed by #6040
Assignees
Labels
good first issue Good for newcomers scope: front Issues that are affecting the frontend side only size: minutes

Comments

@Bonapara
Copy link
Member

Current behavior

I cannot reset the value of Select fields

CleanShot.2024-06-25.at.10.52.45.mp4

Desired Behavior

Users should be able to set no value for a select field. Clicking on the selected value should remove it.

@Bonapara Bonapara added good first issue Good for newcomers scope: front Issues that are affecting the frontend side only size: minutes labels Jun 25, 2024
Copy link

greptile-apps bot commented Jun 25, 2024

To implement the ability to reset the selected field value to empty:

  1. Modify SelectFieldDisplay Component:

    • File: frontend/components/SelectFieldDisplay.js
    • Add a click event handler to set the field value to null.
    const handleClearSelection = () => {
      setFieldValue(null);
    };
    
    return (
      <div onClick={handleClearSelection}>
        {/* existing code */}
      </div>
    );
  2. Update useSelectField Hook:

    • File: frontend/hooks/useSelectField.js
    • Ensure the hook correctly updates the state to reflect the empty value.
    const useSelectField = () => {
      const [value, setValue] = useState(null);
      
      const clearValue = () => setValue(null);
      
      return { value, setValue, clearValue };
    };
  3. Update useClearField Hook:

    • File: frontend/hooks/useClearField.js
    • Ensure the hook correctly updates the state to reflect the empty value.
    const useClearField = (field) => {
      field.setValue(null);
    };

References

@DubemObi
Copy link

Hello, I'll like to work on this can you please assign to me

@Bonapara
Copy link
Member Author

Sure @DubemObi, thanks for contributing!

@Weiko
Copy link
Member

Weiko commented Jun 27, 2024

Closing this issue in favour of #6064 as discussed with @FelixMalfait and @Bonapara

@Weiko Weiko closed this as completed Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers scope: front Issues that are affecting the frontend side only size: minutes
Projects
Status: ✅ Done
Development

Successfully merging a pull request may close this issue.

3 participants