Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(combobox): only set aria-controls when open, fix reference id to list #2575

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"build:react": "yarn workspace @digdir/designsystemet-react build",
"build:tokens": "yarn workspace @digdir/designsystemet-cli build",
"build:css": "yarn workspace @digdir/designsystemet-css build",
"build:storybook": "storybook build -o ./dist/storybook --config-dir ./apps/storybook",
"build:storybook": "storybook build -o ./apps/storybook/dist --config-dir ./apps/storybook",
"build:storefront": "yarn workspace storefront building",
"build:devsite": "yarn workspace dev building",
"start:storefront": "yarn workspace storefront start",
Expand Down
6 changes: 6 additions & 0 deletions packages/react/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [0.63.1](https://github.com/digdir/designsystemet/compare/@digdir/[email protected]...@digdir/[email protected]) (2024-10-08)

### Bug Fixes

- **combobox:** only set `aria-controls` when open ([4d205ad](https://github.com/digdir/designsystemet/commit/4d205adb8d99a06f8add29b146f10b9b5fd51c33))

# [0.63.0](https://github.com/digdir/designsystemet/compare/@digdir/[email protected]...@digdir/[email protected]) (2024-06-07)

### Bug Fixes
Expand Down
2 changes: 1 addition & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@digdir/designsystemet-react",
"version": "0.63.0",
"version": "0.63.1",
"description": "React components for Designsystemet",
"author": "Designsystemet team",
"repository": "https://github.com/digdir/designsystemet",
Expand Down
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,4 +1,4 @@
import { useState, useRef, useEffect, useId, forwardRef } from 'react';
import { useState, useRef, useEffect, forwardRef } from 'react';
import type * as React from 'react';
import { FloatingFocusManager, FloatingPortal } from '@floating-ui/react';
import cl from 'clsx/lite';
Expand Down Expand Up @@ -159,8 +159,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 || '');

const {
Expand Down Expand Up @@ -385,7 +383,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 @@ -407,7 +405,6 @@ export const ComboboxComponent = forwardRef<HTMLInputElement, ComboboxProps>(
visuallyHiddenDismiss
>
<Box
id={listId}
shadow='md'
borderRadius='md'
borderColor='default'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export 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
Loading