-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Reorganized components in advanced filter dropdown #11089
Reorganized components in advanced filter dropdown #11089
Conversation
…lterRecordFilterRow - Abstracted advanced filter record filter group components into AdvancedFilterRecordFilterGroupRow - Moved advanced filter field selection components in AdvancedFilterFieldSelectDrodownButton and AdvancedFilterFieldSelectDrodownContent - Moved advanced filter field selection search input into AdvancedFilterFieldSelectSearchInput - Created AdvancedFilterDropdownRow UI component - Renamed view filter to record filter in modified files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
This PR reorganizes the advanced filter dropdown components to improve code clarity and maintainability, particularly focusing on recursive filter structures and component naming conventions.
- Introduced new components like
AdvancedFilterRecordFilterGroupRow
andAdvancedFilterRecordFilterRow
to clarify recursive filter hierarchy - Abstracted shared UI elements into standalone components (e.g.,
AdvancedFilterDropdownRow
,AdvancedFilterFieldSelectSearchInput
) - Renamed components from "ViewFilter" to "RecordFilter" for consistency across the codebase
- Separated advanced filter code path from view bar simple filter code path while maintaining reusability
- Fixed typo in component naming ('Drodown' instead of 'Dropdown') in
AdvancedFilterFieldSelectDrodownButton
15 file(s) reviewed, 10 comment(s)
Edit PR Review Bot Settings | Greptile
import { objectFilterDropdownIsSelectingCompositeFieldComponentState } from '@/object-record/object-filter-dropdown/states/objectFilterDropdownIsSelectingCompositeFieldComponentState'; | ||
import { useRecoilComponentStateV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentStateV2'; | ||
|
||
export const AdvancedFilterFieldSelectDrodownContent = () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
syntax: Typo in component name: 'Drodown' should be 'Dropdown'
export const AdvancedFilterFieldSelectDrodownContent = () => { | |
export const AdvancedFilterFieldSelectDropdownContent = () => { |
@@ -0,0 +1,53 @@ | |||
import { AdvancedFilterFieldSelectDrodownContent } from '@/object-record/advanced-filter/components/AdvancedFilterFieldSelectDrodownContent'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
syntax: 'Drodown' is misspelled in the import path and component name. Should be 'Dropdown'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
border: none; | ||
border-top: none; | ||
border-bottom: 1px solid ${({ theme }) => theme.border.color.light}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Redundant border declarations. border: none
already sets all borders to none, making border-top: none
unnecessary.
border: none; | |
border-top: none; | |
border-bottom: 1px solid ${({ theme }) => theme.border.color.light}; | |
border: none; | |
border-bottom: 1px solid ${({ theme }) => theme.border.color.light}; |
export const AdvancedFilterRecordFilterOperandSelect = ({ | ||
recordFilterId, | ||
}: AdvancedFilterRecordFilterOperandSelectProps) => { | ||
const dropdownId = `advanced-filter-view-filter-operand-${recordFilterId}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
syntax: dropdownId still contains 'view-filter' in the string template despite the component being renamed to use 'record-filter'
flex-direction: column; | ||
gap: ${({ theme }) => theme.spacing(2)}; | ||
padding: ${({ theme }) => theme.spacing(2)}; | ||
overflow: hidden; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: overflow: hidden may clip dropdown menus in nested filter groups
@@ -0,0 +1,44 @@ | |||
import { AdvancedFilterDropdownRow } from '@/object-record/advanced-filter/components/AdvancedFilterDropdownRow'; | |||
import { AdvancedFilterFieldSelectDrodownButton } from '@/object-record/advanced-filter/components/AdvancedFilterFieldSelectDrodownButton'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
syntax: Typo in import name 'AdvancedFilterFieldSelectDrodownButton' (missing 'w' in 'Dropdown')
import { AdvancedFilterFieldSelectDrodownButton } from '@/object-record/advanced-filter/components/AdvancedFilterFieldSelectDrodownButton'; | |
import { AdvancedFilterFieldSelectDropdownButton } from '@/object-record/advanced-filter/components/AdvancedFilterFieldSelectDropdownButton'; |
<ObjectFilterDropdownComponentInstanceContext.Provider | ||
value={{ instanceId: `advanced-filter-${recordFilter.id}` }} | ||
> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Consider memoizing the context value to prevent unnecessary re-renders of child components
export const AdvancedFilterValueInputDropdownButton = ({ | ||
recordFilterId, | ||
}: AdvancedFilterValueInputDropdownButtonProps) => { | ||
const dropdownId = `advanced-filter-view-filter-value-input-${recordFilterId}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
syntax: dropdownId still contains 'view-filter' in string despite renaming to recordFilter
const dropdownId = `advanced-filter-view-filter-value-input-${recordFilterId}`; | |
const dropdownId = `advanced-filter-record-filter-value-input-${recordFilterId}`; |
clickableComponent={ | ||
<StyledValueDropdownContainer> | ||
{operandHasNoInput ? ( | ||
<></> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: consider using null instead of empty fragment for consistency with other null returns in the codebase
import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/DropdownMenuItemsContainer'; | ||
import { useRecoilComponentStateV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentStateV2'; | ||
import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2'; | ||
import { useSetRecoilComponentStateV2 } from '@/ui/utilities/state/component-state/hooks/useSetRecoilComponentStateV2'; | ||
import { useState } from 'react'; | ||
import { isDefined } from 'twenty-shared'; | ||
import { IconApps, IconChevronLeft, MenuItem, useIcons } from 'twenty-ui'; | ||
import { DropdownMenuHeaderLeftComponent } from '@/ui/layout/dropdown/components/DropdownMenuHeader/internal/DropdownMenuHeaderLeftComponent'; | ||
|
||
export const ObjectFilterDropdownFilterSelectCompositeFieldSubMenu = () => { | ||
const [searchText] = useState(''); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: searchText state is defined but never used since the search input is commented out
margin: 0; | ||
outline: none; | ||
padding: ${({ theme }) => theme.spacing(2)}; | ||
min-height: 19px; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks wrong but I guess it was already there!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed. Let's see if I can tackle it in another PR !
This PR essentially focuses on a refactor of the component hierarchy and naming in advanced filter dropdown, to make it more readable and easy to maintain. This refactor was required because this area of the code is recursive, so it's better to see the same abstract components in the recursion, instead of trying to guess whether we have the same components than the level above or not. Also keep in mind that this refactor is meant to separate the advanced filter code path from the view bar simple filter code path, while reusing what's reusable, so here we have a first attempt at finding the sweet spot, that we'll be able to duplicate on other filter dropdown use cases. - We now use AdvancedFilterRecordFilterGroupRow and AdvancedFilterRecordFilterRow to make it clearer in the advanced filter dropdown recursion where we are. - Children component of AdvancedFilterRecordFilterRow have been abstracted at the same level to make reading easier - The field selection dropdown is now in a self-explanatory component that follows the same naming pattern as other dropdowns in the app : AdvancedFilterFieldSelectDrodownButton, together with AdvancedFilterFieldSelectDrodownContent. - The field selection search in the filter dropdown is now a standalone component : AdvancedFilterFieldSelectSearchInput - The UI container of a row has been abstracted in a new AdvancedFilterDropdownRow Miscellaneous : - Renamed a bunch of view filter old naming to record filter naming.
This PR essentially focuses on a refactor of the component hierarchy and naming in advanced filter dropdown, to make it more readable and easy to maintain.
This refactor was required because this area of the code is recursive, so it's better to see the same abstract components in the recursion, instead of trying to guess whether we have the same components than the level above or not.
Also keep in mind that this refactor is meant to separate the advanced filter code path from the view bar simple filter code path, while reusing what's reusable, so here we have a first attempt at finding the sweet spot, that we'll be able to duplicate on other filter dropdown use cases.
Miscellaneous :