Skip to content

Commit

Permalink
fix: AutoComplete prop type with AllHTMLAttributes and spread props i…
Browse files Browse the repository at this point in the history
…nto input
  • Loading branch information
juliajforesti committed Sep 14, 2023
1 parent bbe8890 commit 93fbb66
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions packages/fuselage/src/components/AutoComplete/AutoComplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ import {
useMutableCallback,
useResizeObserver,
} from '@rocket.chat/fuselage-hooks';
import type { ComponentProps, ElementType, ReactElement } from 'react';
import type {
AllHTMLAttributes,
ComponentProps,
ElementType,
ReactElement,
} from 'react';
import React, { useEffect, useRef, useMemo, useState } from 'react';

import AnimatedVisibility from '../AnimatedVisibility';
Expand Down Expand Up @@ -37,7 +42,7 @@ type AutoCompleteProps = {
error?: boolean;
disabled?: boolean;
multiple?: boolean;
};
} & Omit<AllHTMLAttributes<HTMLInputElement>, 'onChange'>;

const getSelected = (
value: string | string[],
Expand All @@ -64,6 +69,7 @@ export function AutoComplete({
error,
disabled,
multiple,
...props
}: AutoCompleteProps): ReactElement {
const ref = useRef();
const { ref: containerRef, borderBoxSize } = useResizeObserver();
Expand Down Expand Up @@ -134,7 +140,7 @@ export function AutoComplete({
alignItems='center'
flexWrap='wrap'
margin='neg-x4'
role='listbox'
role='group'
>
<Margins all='x4'>
<InputBox.Input
Expand All @@ -153,8 +159,9 @@ export function AutoComplete({
order={1}
rcx-input-box--undecorated
value={filter}
{...props}
/>
{selected &&
{selected?.length > 0 &&
selected.map((itemSelected) =>
RenderSelected ? (
<RenderSelected
Expand All @@ -164,7 +171,6 @@ export function AutoComplete({
/>
) : (
<Chip
role='option'
key={itemSelected.value}
value={itemSelected.value}
label={itemSelected.label}
Expand Down

0 comments on commit 93fbb66

Please sign in to comment.