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(components): fix incorrect usage of useid #6491

Merged
merged 1 commit into from
Nov 14, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { palette } from '@leafygreen-ui/palette';
import { rgba } from 'polished';
import { useDarkMode } from '../hooks/use-theme';
import { useHotkeys } from '../hooks/use-hotkeys';
import { useId } from '@react-aria/utils';

const borderRadius = spacing[2];

Expand Down Expand Up @@ -162,7 +161,7 @@ function InteractivePopover({

useHotkeys('Escape', onClose, { enabled: open }, [onClose]);

const closeButtonId = useId('close-button-id');
const closeButtonId = 'close-button-id';

return trigger({
onClick: onClickTrigger,
Expand Down
8 changes: 4 additions & 4 deletions packages/compass-components/src/hooks/use-sort.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe('use-sort', function () {
expect(
screen
.getByRole('button', {
name: /title/i,
name: 'Sort by',
})
.getAttribute('aria-disabled')
).to.equal('true');
Expand All @@ -70,7 +70,7 @@ describe('use-sort', function () {
// Opens dropdown
userEvent.click(
screen.getByRole('button', {
name: /title/i,
name: 'Sort by',
}),
undefined,
{
Expand Down Expand Up @@ -111,7 +111,7 @@ describe('use-sort', function () {
// Opens dropdown
userEvent.click(
screen.getByRole('button', {
name: /title/i,
name: 'Sort by',
}),
undefined,
{
Expand Down Expand Up @@ -141,7 +141,7 @@ describe('use-sort', function () {
// Opens dropdown
userEvent.click(
screen.getByRole('button', {
name: /title/i,
name: 'Sort by',
}),
undefined,
{
Expand Down
2 changes: 1 addition & 1 deletion packages/compass-components/src/hooks/use-sort.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export function useSortControls<T extends string>(
items: readonly { name: T; label: string }[],
options?: SortOptions
): [React.ReactElement, SortState<Unwrap<typeof items>['name']>] {
const labelId = useId('Sort by');
const labelId = 'sort-by';
const controlId = useId();

const [sortState, dispatch] = useReducer(
Expand Down
Loading