Skip to content

Commit

Permalink
Fix Combobox - React doesn't recognise isError prop; Fix Combobox - F…
Browse files Browse the repository at this point in the history
…unction components refs
  • Loading branch information
moon-ds committed Sep 19, 2023
1 parent 922e889 commit de7ff14
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions workspaces/core/src/combobox/Combobox.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import React from 'react';
'use client'

import React, { forwardRef } from 'react';
import {
Combobox as HeadlessCombobox,
Transition as HeadlessTransition,
Expand Down Expand Up @@ -105,11 +107,13 @@ const ComboboxRoot = ({
);
};

const Trigger = ({
const Trigger = forwardRef<HTMLDivElement, WithChildren<SelectProps>>(({
children,
className,
innerLabel,
}: WithChildren<SelectProps>) => {
},
ref
) => {
const { size, input, popper, disabled, isError } =
useComboboxContext('Combobox.Trigger');

Expand All @@ -136,7 +140,7 @@ const Trigger = ({
{children}
</div>
);
};
});

const Input = ({
displayValue,
Expand All @@ -153,7 +157,6 @@ const Input = ({
onChange={({ target: { value } }) => {
onQueryChange ? onQueryChange(value) : () => {};
}}
ref={popper?.setAnchor}
as={NativeInput}
displayValue={displayValue}
placeholder={placeholder}
Expand All @@ -165,11 +168,12 @@ const Input = ({
className
)}
disabled={disabled}
isError={isError}
error={isError}
onFocus={() => input?.setIsFocused(true)}
onBlur={() => input?.setIsFocused(false)}
aria-label={rest['aria-label']}
{...rest}
ref={popper?.setAnchor}
/>
);
};
Expand All @@ -190,7 +194,6 @@ const InsetInput = ({
onChange={({ target: { value } }) => {
onQueryChange ? onQueryChange(value) : () => {};
}}
ref={popper?.setAnchor}
as={NativeInput}
displayValue={displayValue}
placeholder={placeholder === undefined ? '' : `${placeholder}`}
Expand All @@ -208,11 +211,12 @@ const InsetInput = ({
className,
'leading-5'
)}
isError={isError}
error={isError}
onFocus={() => input?.setIsFocused(true)}
onBlur={() => input?.setIsFocused(false)}
aria-label={rest['aria-label']}
{...rest}
ref={popper?.setAnchor}
/>
<InputInset.Label className="w-auto -top-0.5 !inset-x-0 whitespace-nowrap overflow-x-hidden">
{label}
Expand Down

0 comments on commit de7ff14

Please sign in to comment.