Skip to content

Commit

Permalink
chore(combobox): sync with main changes (#2576)
Browse files Browse the repository at this point in the history
this PR is only to reflect changes made in an older version in PR #2575
  • Loading branch information
Barsnes authored Oct 8, 2024
1 parent bad8f49 commit ef73ac3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
7 changes: 2 additions & 5 deletions packages/react/src/components/form/Combobox/Combobox.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { FloatingFocusManager, FloatingPortal } from '@floating-ui/react';
import { useVirtualizer } from '@tanstack/react-virtual';
import cl from 'clsx/lite';
import { forwardRef, useEffect, useId, useRef, useState } from 'react';
import { forwardRef, useEffect, useRef, useState } from 'react';
import type { InputHTMLAttributes, ReactNode } from 'react';

import type { PortalProps } from '../../../types/Portal';
Expand Down Expand Up @@ -156,8 +156,6 @@ export const ComboboxComponent = forwardRef<HTMLInputElement, ComboboxProps>(
const portalRef = useRef<HTMLDivElement>(null);
const listRef = useRef<Array<HTMLElement | null>>([]);

const listId = useId();

const [inputValue, setInputValue] = useState<string>(rest.inputValue || '');

useEffect(() => {
Expand Down Expand Up @@ -396,7 +394,7 @@ export const ComboboxComponent = forwardRef<HTMLInputElement, ComboboxProps>(
<ComboboxInput
{...omit(['inputValue'], rest)}
hideClearButton={hideClearButton}
listId={listId}
listId={context.floatingId}
error={error}
hideChips={hideChips}
handleKeyDown={handleKeyDown}
Expand All @@ -417,7 +415,6 @@ export const ComboboxComponent = forwardRef<HTMLInputElement, ComboboxProps>(
visuallyHiddenDismiss
>
<div
id={listId}
aria-labelledby={formFieldProps.inputProps.id}
aria-autocomplete='list'
tabIndex={-1}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ const ComboboxInput = ({
aria-autocomplete='list'
role='combobox'
aria-expanded={open}
aria-controls={listId}
aria-controls={open ? listId : undefined}
autoComplete='off'
size={htmlSize}
value={inputValue}
Expand Down

0 comments on commit ef73ac3

Please sign in to comment.