-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/rocketchat-icon
- Loading branch information
Showing
7 changed files
with
146 additions
and
139 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@rocket.chat/fuselage": patch | ||
--- | ||
|
||
Memory leak in `PaginatedMultiSelect` |
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
74 changes: 74 additions & 0 deletions
74
packages/fuselage/src/components/PaginatedSelect/PaginatedMultiSelectFiltered.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 |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import type { ComponentProps, Ref, FormEvent, ReactElement } from 'react'; | ||
import React, { useCallback, forwardRef } from 'react'; | ||
|
||
import type Box from '../Box'; | ||
import Flex from '../Flex'; | ||
import { InputBox } from '../InputBox'; | ||
import { type OptionsPaginated } from '../OptionsPaginated'; | ||
import PaginatedMultiSelect, { | ||
type PaginatedMultiSelectOption, | ||
} from './PaginatedMultiSelect'; | ||
|
||
type PaginatedMultiSelectFilteredProps = Omit< | ||
ComponentProps<typeof Box>, | ||
'onChange' | 'value' | 'filter' | ||
> & { | ||
error?: boolean; | ||
options: PaginatedMultiSelectOption[]; | ||
withTitle?: boolean; | ||
placeholder?: string; | ||
endReached?: (start?: number, end?: number) => void; | ||
value?: PaginatedMultiSelectOption[]; | ||
onChange: (values: PaginatedMultiSelectOption[]) => void; | ||
renderOptions?: ( | ||
props: ComponentProps<typeof OptionsPaginated> | ||
) => ReactElement | null; | ||
anchor?: any; | ||
filter?: string; | ||
setFilter?: (value: string) => void; | ||
}; | ||
|
||
export const PaginatedMultiSelectFiltered = ({ | ||
filter, | ||
setFilter, | ||
options, | ||
placeholder, | ||
...props | ||
}: PaginatedMultiSelectFilteredProps) => { | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
const anchor = useCallback( | ||
forwardRef( | ||
( | ||
{ | ||
children: _children, | ||
filter, | ||
...props | ||
}: ComponentProps<typeof InputBox>, | ||
ref: Ref<HTMLInputElement> | ||
) => ( | ||
<Flex.Item grow={1}> | ||
<InputBox.Input | ||
ref={ref} | ||
placeholder={placeholder} | ||
value={filter} | ||
onInput={(e: FormEvent<HTMLInputElement>) => | ||
setFilter?.(e.currentTarget.value) | ||
} | ||
{...props} | ||
rcx-input-box--undecorated | ||
/> | ||
</Flex.Item> | ||
) | ||
), | ||
[] | ||
); | ||
|
||
return ( | ||
<PaginatedMultiSelect | ||
filter={filter} | ||
options={options} | ||
{...props} | ||
anchor={anchor} | ||
/> | ||
); | ||
}; |
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
Oops, something went wrong.