-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: ♻️ Improve UsersTableFilters and MultiSelectCustom components
Changed the implementation of the new users table filters from a fully custom "Box based" code to a standardized use of the FilterByText component with children. Also improved the positioning and styling of the MultiSelectCustom by properly implementing the useOutsideClick and usePosition custom hooks together with reusing the fuselage button and input styles in the anchor of the component.
- Loading branch information
Showing
4 changed files
with
55 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 26 additions & 12 deletions
38
packages/ui-client/src/components/MultiSelectCustom/MultiSelectCustomListWrapper.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,29 @@ | ||
import { Box } from '@rocket.chat/fuselage'; | ||
import { forwardRef, type ComponentProps } from 'react'; | ||
|
||
const MultiSelectCustomListWrapper = forwardRef<Element, ComponentProps<typeof Box>>(function MultiSelectCustomListWrapper( | ||
{ children }, | ||
ref, | ||
) { | ||
return ( | ||
<Box ref={ref} zIndex='2' w='full' position='absolute' mbs={40} pbs={4}> | ||
{children} | ||
</Box> | ||
); | ||
}); | ||
import { useOutsideClick, usePosition } from '@rocket.chat/fuselage-hooks'; | ||
import { forwardRef, useRef, type ComponentProps } from 'react'; | ||
|
||
const options = { | ||
margin: 8, | ||
placement: 'bottom-end', | ||
} as const; | ||
|
||
const hidden = { | ||
visibility: 'hidden', | ||
opacity: 0, | ||
position: 'fixed', | ||
} as const; | ||
|
||
const MultiSelectCustomListWrapper = forwardRef<Element, ComponentProps<typeof Box> & { onClose: (e: MouseEvent) => void }>( | ||
function MultiSelectCustomListWrapper({ children, onClose }, ref) { | ||
const target = useRef<HTMLElement>(null); | ||
useOutsideClick([target], onClose); | ||
const { style = hidden } = usePosition(ref as Parameters<typeof usePosition>[0], target, options); | ||
return ( | ||
<Box ref={target} style={style} minWidth={224} zIndex='99999'> | ||
{children} | ||
</Box> | ||
); | ||
}, | ||
); | ||
|
||
export default MultiSelectCustomListWrapper; |