twentyhq / twenty

Building a modern alternative to Salesforce, powered by the community.
https://twenty.com
GNU Affero General Public License v3.0
15.18k stars 1.53k forks source link

Filter "Is Empty" / "Is not Empty" broken #6079

Open Bonapara opened 3 weeks ago

Bonapara commented 3 weeks ago

Description

When clicking outside, the filter gets reinitialized. It's also impossible to save the view.

https://github.com/twentyhq/twenty/assets/19412894/f4d98d77-10fc-4d1f-b752-045b44c05ea5

How to reproduce

Go to the People object and try to filter by Employees == Not null

How it should behave

The blue chip should remain in the filter bar when the menu is closed.

greptile-apps[bot] commented 3 weeks ago

To resolve the issue where the filter 'Is Empty' / 'Is not Empty' gets reinitialized when clicking outside, follow these steps:

  1. Update EditableFilterDropdownButton.tsx:

    • Modify the handleDropdownClickOutside function to prevent reinitialization of the filter when clicking outside.
      const handleDropdownClickOutside = useCallback(() => {
      // Remove the condition that checks for value
      // const { id: fieldId, value } = viewFilter;
      // if (!value) {
      //   removeCombinedViewFilter(fieldId);
      // }
      }, [viewFilter, removeCombinedViewFilter]);
  2. Ensure Proper State Management in useFilterDropdown.ts:

    • Verify that the state management for the filter dropdown does not reset the filter on outside click.
    • Specifically, check the resetFilter and emptyFilterButKeepDefinition functions to ensure they are not being called unintentionally.
  3. Check ViewBarFilterEffect.tsx:

    • Ensure that the effect hook managing the filter state does not reset the filter when clicking outside.
    • Verify the dependencies of the effect hook to ensure it only updates when necessary.

These changes should address the issue of the filter getting reinitialized when clicking outside and make it possible to save the view.

References

/packages/twenty-front/src/modules/object-record/object-filter-dropdown/hooks/useFilterDropdown.ts /packages/twenty-front/src/modules/views/components/EditableFilterDropdownButton.tsx /packages/twenty-front/src/modules/views/hooks/useCombinedViewFilters.ts /packages/twenty-front/src/modules/object-record/object-filter-dropdown/components/ObjectFilterDropdownFilterSelect.tsx /packages/twenty-front/src/modules/views/components/ViewBarFilterEffect.tsx

#### About Greptile This response provides a starting point for your research, not a precise solution. Help us improve! Please leave a ๐Ÿ‘ if this is helpful and ๐Ÿ‘Ž if it is irrelevant. [Ask Greptile](https://app.greptile.com/chat/github/twentyhq/twenty/main) ยท [Edit Issue Bot Settings](https://app.greptile.com/apps/github)