diff --git a/app/javascript/components/ComboBox.tsx b/app/javascript/components/ComboBox.tsx index 7fe18b80b..19dc45707 100644 --- a/app/javascript/components/ComboBox.tsx +++ b/app/javascript/components/ComboBox.tsx @@ -18,7 +18,6 @@ import { findOrCreateContainerElement } from '@coldwired/react'; import * as s from 'superstruct'; import { - useLabelledBy, useDispatchChangeEvent, useMultiList, useSingleList, @@ -94,7 +93,6 @@ export function SingleComboBox({ ...maybeProps }: SingleComboBoxProps) { const { - 'aria-labelledby': ariaLabelledby, items: defaultItems, selectedKey: defaultSelectedKey, emptyFilterKey, @@ -105,7 +103,6 @@ export function SingleComboBox({ ...props } = useMemo(() => s.create(maybeProps, SingleComboBoxProps), [maybeProps]); - const labelledby = useLabelledBy(props.id, ariaLabelledby); const { ref, dispatch } = useDispatchChangeEvent(); const { selectedItem, onReset, ...comboBoxProps } = useSingleList({ @@ -117,12 +114,7 @@ export function SingleComboBox({ return ( <> - + {(item) => {item.label}} {children || name ? ( @@ -147,7 +139,6 @@ export function SingleComboBox({ export function MultiComboBox(maybeProps: MultiComboBoxProps) { const { - 'aria-labelledby': ariaLabelledby, items: defaultItems, selectedKeys: defaultSelectedKeys, name, @@ -159,7 +150,6 @@ export function MultiComboBox(maybeProps: MultiComboBoxProps) { ...props } = useMemo(() => s.create(maybeProps, MultiComboBoxProps), [maybeProps]); - const labelledby = useLabelledBy(props.id, ariaLabelledby); const { ref, dispatch } = useDispatchChangeEvent(); const inputRef = useRef(null); @@ -202,7 +192,6 @@ export function MultiComboBox(maybeProps: MultiComboBoxProps) { ) : null} s.create(maybeProps, RemoteComboBoxProps), [maybeProps]); - const labelledby = useLabelledBy(props.id, ariaLabelledby); const { ref, dispatch } = useDispatchChangeEvent(); const load = useMemo( @@ -288,7 +275,6 @@ export function RemoteComboBox({ 0} allowsCustomValue={allowsCustomValue} - aria-labelledby={labelledby} {...comboBoxProps} {...props} > diff --git a/app/javascript/components/react-aria/hooks.ts b/app/javascript/components/react-aria/hooks.ts index 5df65dda7..31022d9e8 100644 --- a/app/javascript/components/react-aria/hooks.ts +++ b/app/javascript/components/react-aria/hooks.ts @@ -510,24 +510,6 @@ export const createLoader: ( } }; -export function useLabelledBy(id?: string, ariaLabelledby?: string) { - return useMemo( - () => (ariaLabelledby ? ariaLabelledby : findLabelledbyId(id)), - [id, ariaLabelledby] - ); -} - -function findLabelledbyId(id?: string) { - if (!id) { - return; - } - const label = document.querySelector(`[for="${id}"]`); - if (!label?.id) { - return; - } - return label.id; -} - export function useOnFormReset(onReset?: () => void) { const ref = useRef(null); const onResetListener = useEvent((event) => {